Repository navigation
Check each case of a switch from the state before it - #497
Open
CatarinaGamboa wants to merge 2 commits into
Open
CatarinaGamboa wants to merge 2 commits into
CatarinaGamboa wants to merge 2 commits into
Conversation
A switch is checked as the chain of ifs that tests its labels: each case knows the selector equals one of its labels (the default case, none of the others), starts from the state before the switch, falls through into the next case when it does not break, and the states of the cases that reach the end are joined after it. Switch expressions are checked the same way. Pattern and guarded cases keep the previous checking. A break or yield nested inside a case's statements is not followed: what those cases change is forgotten on that path. Fixes #494 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Codex review, round 1
|
…er it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Round 1 replies:
|
Collaborator
Author
|
Codex review, round 2: no findings ("I found no actionable regressions in the diff. The verifier test suite passed."). |
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.
Fixes #494
The verifier had no
switchhandling, so the cases ran one after another as straight-line code:breakwas ignored and thecaselabel never entered the path condition. Aswitchis now checked like theif/else ifchain over its labels:selector == label(grouped labels: any of them;default: none of the other labels)breakfalls through into the next oneifreturn/throw/continuein a case drop that path, as in anif->,yield) are checked the same way; selectors may be enums, ints or strings (a string label has no known value, so it adds no path condition)Two forms are handled conservatively:
case String s ->,when): checked as before (Verifier crashes on a type-pattern switch (case String s ->) #345 is unchanged)break/yieldnested inside a case (e.g.if (c) { ...; break; }): the state at that jump is not followed, so what those cases change is forgotten on that path after the switch (shown astruein Found)Study exercise A1_09 (litiengine), the partial fix
else if (newMode == BORDERLESS) host.dispose();Before, the same error at the same line, though BORDERLESS is now disposed:
After, the error moves to the remaining bug, the full-screen fallback:
Study exercise A1_56 (JabRef), only
redo()guardedBefore, the UNDO case saw what the REDO case did:
After, only what holds on the UNDO path:
The six study exercises still report their error at the same line. A1_09's Found now starts with the case's label:
found newMode == BORDERLESS && (...). The other study variants report the same as before, apart from A1_09's first-only fix: same line (63), but its Found wasdisplayable(host), the state the BORDERLESS case left, and is now the full-screen path'snewMode == FULLSCREEN && (...), longer than before.Tests:
CorrectEnumUsage(state and label of each case, switch statement and expression),ErrorEnumUsage(an error that was missed in a case reached directly and by fall-through, and the nestedbreak).TestStateHintsnow expects A1_56's UNDO hints above. Each fails onmain.🤖 Generated with Claude Code