inject pre-finally and after-finally edges into flow graph to possibly ignore pre-finally during flow walk #13845
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix proposal for #12205
I've tried the approach with copying the flow graph in finally block and decided not to use it since in presence of nested try-finally blocks in becomes quite complicated. As an alternative I'd like to propose different approach: for try-finally blocks we inject two extra edges in the flow graph. One edge will link pre-try flow with pre-finally label, another will act as a proxy for post-finally flow. If during the flow walk we touch the post-finally flow edge we can mark matching pre-finally edge as blocked so it will be ignored. The overhead of this approach is also much smaller than copying - max two objects per protected region which sounds like a reasonable thing.
// cc @ahejlsberg, @mhegazy