Repository navigation
fix(aiken-lang): stop when clause variables receiving each other's values - #1463
Open
logicalmechanism wants to merge 2 commits into
Open
logicalmechanism wants to merge 2 commits into
logicalmechanism wants to merge 2 commits into
Conversation
…t order The body of a `when` clause is hoisted into a function shared by every leaf that reaches it, and receives the clause's variables by position. The parameter order came from the first leaf built, but each leaf passed the variables in the order its own row collected them, which depends on the order columns were specialized on that branch. When two branches differed, the variables received each other's values. Make every leaf pass the order recorded for the clause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a regression test shaped like a state transition check, where the swap inverts the comparison on one branch only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Variables bound by a
whenclause can silently receive each other's values.On current
main,allowed(Withdraw, Some(100), Some(60))returnsTrueandallowed(Withdraw, Some(100), Some(120))returnsFalse. The same inputs withUpdateorDepositare correct.Cause: a clause body is hoisted into a function shared by every leaf that reaches it, and takes its variables by position. The parameter order came from the first leaf built, but each leaf passed the variables in the order its own row collected them, which depends on which column was specialized first on that branch. Above, the
Depositbranch testsoldfirst and theWithdrawbranch testsnewfirst.Fix: every leaf now passes the order recorded for the clause. The comment saying the list could simply be overwritten is replaced, since that assumption was the bug.
Effect on scripts: output only changes when a clause's leaves disagreed on the order. That includes scripts where the swap had no visible effect, such as
a + b, so those can get a new hash. The changelog entry says so.Checked:
mainand pass with this change.whenprograms with bound variables, checked against an independent matcher, it fixed 4, caused no new failures, and changed the hash of only those 4.🤖 Generated with Claude Code