fix(ssa): preserve truncating cast chain boundary - #13388
Open
1sgtpepper wants to merge 1 commit into
Open
Conversation
Contributor
|
Thank you for your contribution to the Noir language. Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch. Thanks for your understanding. |
1sgtpepper
force-pushed
the
fix-cast-chain-boundary
branch
from
July 22, 2026 12:00
d9959fd to
10037a5
Compare
1sgtpepper
marked this pull request as ready for review
July 22, 2026 12:01
1sgtpepper
force-pushed
the
fix-cast-chain-boundary
branch
from
July 22, 2026 12:48
10037a5 to
a96b0cf
Compare
1sgtpepper
force-pushed
the
fix-cast-chain-boundary
branch
from
July 22, 2026 13:08
a96b0cf to
45b611c
Compare
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.
Problem Resolved
Resolves #12844
Summary of Changes
Preserves an intermediate cast whenever collapsing it would change truncation or extension behavior. For
-1i8 as u8 as i16, theu8boundary must produce255; replacing the chain with directi8 -> i16widening would produce-1.The legality check compares all three widths and signedness roles, and collapses only cast chains that compose exactly. The behavior test covers the reported case, the opposite unsigned→signed boundary, narrow-then-widen chains, and a wider unsigned intermediate. Two existing SSA snapshots retain their proven intermediate casts.
User Documentation
Check one:
PR Checklist
cargo fmton default settings.Validation:
cargo test -p noirc_evaluator --libcargo clippy -p noirc_evaluator --lib -- -D warningscargo fmt --check