bugfix(lowering): Removed extra diag in cases of out of range u256 match. - #10006
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryLow Risk Overview Previously, a failed The change drops unreachable arms ( New match graph tests cover out-of-range literal before Reviewed by Cursor Bugbot for commit 900dec8. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 842eb7635d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
842eb76 to
900dec8
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi resolved 1 discussion.
Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on eytan-starkware and TomerStarkware).
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 2 files reviewed, all discussions resolved (waiting on eytan-starkware).
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 1 file.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
When a
u256match arm contains an out-of-range literal (triggeringE3009) followed by a wildcard arm, the code previously failed to push aNoneentry intopatterns_on_current_itemfor the invalid literal case. This broke the one-entry-per-arm invariant, causing the wildcard arm's entry to be misaligned, which produced a spuriousE3004non-exhaustive match error in addition to the legitimateE3009diagnostic.The fix adds an
elsebranch that pushesNonewhenhandle_u256_literaldoes not return an inner pattern, preserving the invariant and ensuring only the correctE3009diagnostic is emitted.Type of change
Please check one:
Why is this change needed?
When a
u256pattern literal was out of range, the missingNonepush caused subsequent arm entries to be offset by one position relative to their expected index. This misalignment made the match appear non-exhaustive even when a wildcard_arm was present, emitting a falseE3004diagnostic alongside the realE3009.What was the behavior or documentation before?
A match on
u256with an out-of-range literal followed by a wildcard arm would emit bothE3009(value out of range) and a spuriousE3004(non-exhaustive match).What is the behavior or documentation after?
The same match now emits only
E3009. The wildcard arm is correctly recognized, and no false non-exhaustive diagnostic is produced.Related issue or discussion (if any)
N/A
Additional context
A new test case
Match u256 with out-of-range literal before wildcardis added to the match test data to cover this scenario, verifying that onlyE3009appears and noE3004is emitted.