Skip to content

fix: compound assignment with side-effect in lhs miscompiles#2992

Open
XMadrid wants to merge 8 commits intoAssemblyScript:mainfrom
XMadrid:fix/2730
Open

fix: compound assignment with side-effect in lhs miscompiles#2992
XMadrid wants to merge 8 commits intoAssemblyScript:mainfrom
XMadrid:fix/2730

Conversation

@XMadrid
Copy link
Contributor

@XMadrid XMadrid commented Mar 18, 2026

Fixes #2730 .
This PR fixes a compound-assignment codegen bug where the lhs could be evaluated twice (for example, in patterns like method-call receivers or indexed access), causing duplicated side effects.

Changes proposed in this pull request:
⯈Added a side-effect cache path for compound assignment in the compiler so side-effectful receiver/index expressions are evaluated once and reused.
⯈Introduced helper logic to detect cache-eligible targets (property/element access) and side-effectful sub-expressions
⯈The reason so many test fixtures are affected is that there is a match assignment statement on line 375 of rt/tlsf.ts, which lhs gets compiled twice (which is semantically incorrect).

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@XMadrid XMadrid changed the title Fix/2730 fix/2730 Mar 18, 2026
@XMadrid XMadrid changed the title fix/2730 fix: compound assignment with side-effect in lhs miscompiles Mar 18, 2026
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.

Compound assignment with post increment in lhs miscompiles

1 participant