Repository navigation
A break or continue naming a label no statement around it has is an error - #583
Merged
Merged
Conversation
…rror `continue nolabel;` and `break nolabel;` inside a loop compiled with no diagnostic: the jump op carried a label nothing matched. MLIRGen now keeps the labels of the statements around the code it generates (a function body starts with none, since a jump can't leave a function) and rejects a label that isn't one of them. A continue to the label of a block, which starts the block again (tests/00break_continue.ts), stays: an extension TypeScript doesn't have. 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.
continue nolabel;andbreak nolabel;inside a loop compiled with no diagnostic: the jump op carried a label nothing matched.Fix: MLIRGen keeps the labels of the statements around the code it is generating (
activeLabels; pushed inmlirGen(LabeledStatement), cleared for a function body, since a jump can't leave a function) and rejects a labeledbreak/continuewhose label isn't one of them.Repro (
diagnostic-location/continue_label.ts,break_label.ts):break_label.tshas abreak outerinside an arrow function inside the labeled loop. That is an error, because the label is outside the function. Abreak outerafter the arrow still compiles. The tests fail if a valid jump is reported.Kept on purpose:
continue lblto a labeled block starts the block again (tests/00break_continue.tstest_label). TypeScript rejects it, but this compiler supports it deliberately, so only unknown labels are errors.Not fixed, found while testing:
a: b: for (...) { continue a; }loops forever (the loop's increment is skipped). That codegen bug was there before this PR.ctest -C Release -j 8 --timeout 300: 100% passed, 0 failed (4093 tests on this branch).🤖 Generated with Claude Code