Skip to content

Constrain Yul assignment LHS to word#487

Merged
rodrigogribeiro merged 2 commits into
argotorg:mainfrom
axic:assembly-lhs-assignment
Jun 23, 2026
Merged

Constrain Yul assignment LHS to word#487
rodrigogribeiro merged 2 commits into
argotorg:mainfrom
axic:assembly-lhs-assignment

Conversation

@axic

@axic axic commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

No description provided.

claude and others added 2 commits June 23, 2026 18:36
tcYulStmt YAssign only unified the assignment LHS with `word` when the
variable's type was still a metavariable, letting any concrete non-word
type (bool, data, structs, sums) fall through unconstrained. Assembly
writes a raw scalar, so a non-word LHS corrupts the variable's tagged
inl/inr runtime layout, and the bad write survives every desugaring pass
into Yul codegen.

Unify the LHS type with `word` unconditionally, mirroring the read path
in tcYulExp (YIdent _). Add a negative case test (asm-assign-non-word)
asserting that assigning to a bool LHS in assembly is now rejected.

Co-Authored-By: Alex Beregszaszi <alex@rtfs.hu>

function yul_asm_for_body() -> () {
let result : uint256 = uint256(0);
let result : word = 0;

@axic axic Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three test cases were added in #363 -- makes me wonder if that "fix" wasn't fully correct, and it was eliminated to begin with as the types didn't even match.

@rodrigogribeiro rodrigogribeiro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rodrigogribeiro rodrigogribeiro merged commit d8e8a31 into argotorg:main Jun 23, 2026
4 checks passed
@axic axic deleted the assembly-lhs-assignment branch June 23, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants