Fix bad jump from yield break inside catch in async-iterator#80927
Fix bad jump from yield break inside catch in async-iterator#80927jcouv merged 3 commits intodotnet:mainfrom
Conversation
| tryBlock: F.Block(node.TryBlock, F.Label(finallyEntry)), | ||
| node.CatchBlocks, node.FinallyBlockOpt, node.FinallyLabelOpt, node.PreferFaultHandler); | ||
| tryEnd = F.GenerateLabel("tryEnd"); | ||
| _currentDisposalLabel = tryEnd; |
There was a problem hiding this comment.
According to documentation for _currentDisposalLabel: " Inside a try or catch with a finally, we'll use the label directly preceding the finally." This is no longer accurate. Please adjust documentation accordingly, perhaps also explaining why placing the label there gives us the right control flow. #Closed
| public override BoundNode VisitTryStatement(BoundTryStatement node) | ||
| { | ||
| var savedDisposalLabel = _currentDisposalLabel; | ||
| LabelSymbol tryEnd = null; |
|
|
||
| if (tryEnd != null) | ||
| { | ||
| // Append a label at the end of the `try`, which disposal within `try` can jump to to execute the `finally` (if any): |
|
|
||
| if (tryEnd != null) | ||
| { | ||
| // Append a label at the end of the `try`, which disposal within `try` can jump to to execute the `finally` (if any): |
There was a problem hiding this comment.
// Append a label at the end of the
try, which disposal withintrycan jump to to execute thefinally(if any):
Consider making the comment clearer. Something like: "Append a label immediately after the try-catch-finally statement, which disposal within try/catch blocks jumps to with a goal to pass control flow to the finally block" implicitly" #Closed
|
Done with review pass (commit 2) #Closed |
Fixes #79124
The problem is that given the following code:
We'd lower to a tree like this (output from
DumpSource()with some formatting/cleanups):The fix is to move the label after the
try(output fromDumpSource()):