Repository navigation
break and continue in a for await body, and nested for await (#502) - #505
Merged
Merged
Conversation
`break` or `continue` in the body of a `for await`, and a `for await` nested in another, crashed the compiler (0xC0000005, no message), under every memory model. mlirGen(ForStatement) generated a `for await` body inside an async.execute region of its own (awaited per iteration since #498): a ts.Break / ts.Continue in it had no loop in its region, which the lowering crashed on, and the nested loop crashed MLIR generation. The body is now generated in the loop as any other loop's is. The region was there only so that an `await` in the body had an async region, and an `await` makes its own async.execute and waits for it wherever it is (as in a plain for...of in an async function), so the body still runs one iteration at a time, in order. The ForAwait flag no longer changes the loop's code. 00for_await_control.ts: break, continue, a nested for await, and awaits with continue and break in one body, under every model; on main each crashed the compiler. A for await at module level runs as well. Closes #502 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
breakorcontinuein the body of afor await, and afor awaitnested in another, crashed the compiler (0xC0000005, no message), under every memory model.mlirGen(ForStatement)generated afor awaitbody inside anasync.executeregion of its own, awaited once per iteration since #498. That broke two things:ts.Break/ts.Continuein the body had no loop inside its region, and lowering crashed on it;The body is now generated directly in the loop, like any other loop body. The region existed only to give an
awaitin the body an async region. But anawaitcreates its ownasync.executeand waits for it wherever it appears, as in a plainfor...ofin an async function. So the body still runs one iteration at a time, in order (00for_await_sequential.ts, #498, still passes). TheForAwaitflag no longer changes the loop's code.New test
00for_await_control.tscoversbreak,continue, a nestedfor await, and awaits withcontinueandbreakin one body. It passes under every model; onmaineach of these crashed the compiler. Afor awaitat module level runs as well.tests.ps1 -Model, release + debug, compile + JITweakref_basicskipped (gc only); all "All tests passed"Closes #502
🤖 Generated with Claude Code