Reject continue placed directly in a for update region - #30
Merged
Merged
Conversation
The update list of a classic for loop is that loop's continuation point. A continue there has no later point of the same iteration to reach, and both CorePrep lowerings turned it into a jump back to the start of the update, which skips the condition and never terminates. Source code cannot produce it because a for update is a list of expressions, but Core built or transformed by other means could. Both Core verifiers now track where a transfer would go instead of only a loop depth: outside a loop, in a loop body, or in a for update region. A continue directly in an update region, including inside a branch there, is rejected with VXC1066. A break in an update region stays valid and exits the loop, and a continue in a loop nested inside an update region is valid again because that loop has its own continuation point. Existing diagnostics for transfers outside any loop are unchanged. The Haskell and native verifier suites cover each case, and the Core IR document states the rule.
Leitwolf11
marked this pull request as ready for review
October 2, 2026 19:34
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.
What changed
The update list of a classic
forloop is that loop's continuation point. Acontinueplaced there had no definedtarget: both CorePrep lowerings turned it into a jump back to the start of the update, which skips the condition and
never terminates. Source code cannot produce it, because a
forupdate is a list of expressions, but Core built ortransformed by other means could.
Both Core verifiers now track where a transfer would go (outside a loop, in a loop body, or in a
forupdateregion) instead of only a loop depth.
continuedirectly in an update region, including inside a branch there: rejected withVXC1066.breakin an update region: still valid, exits the loop.continuein a loop nested inside an update region: valid, that loop has its own continuation point.Verification
cabal test visual-xsharp-compiler-tests: PASS, including eight new verifier cases.go run ./helpers/cmd/develop test: all 21 native suites passed (Windows), including the new native verifier case.verify-docsand clang-format: PASS.macOS and Linux were not run locally.