Skip to content

Fix register forwarding when the right operand mutates the left local - #5457

Open
dev-willbird1936 wants to merge 3 commits into
boa-dev:mainfrom
dev-willbird1936:boa-fnd-20260722-bug-0002
Open

Fix register forwarding when the right operand mutates the left local#5457
dev-willbird1936 wants to merge 3 commits into
boa-dev:mainfrom
dev-willbird1936:boa-fnd-20260722-bug-0002

Conversation

@dev-willbird1936

Copy link
Copy Markdown

This Pull Request fixes/closes #5456.

The bytecode compiler can forward the register of a mutable local into a binary operation. It compiles the right operand before it copies the left value into the destination register. When the right operand mutates that local, the generated operation reads the mutated value instead of the value that left-to-right JavaScript evaluation captured, so let a = 1; a = a + (a = 5); produces 10 instead of the specified 6.

This change snapshots mutable local identifiers into a temporary register before the other operand is compiled, and keeps the existing fast path for immutable locals and cached constants. The regression test covers four mutating right-hand operands across arithmetic, bitwise, strict-equality, and relational operators. The existing boa_engine suite is the negative control for unchanged behaviour on ordinary binary expressions.

Validation on current main:

  • cargo test -p boa_engine binary_operands_preserve_left_to_right_evaluation
  • cargo fmt --all -- --check

@dev-willbird1936
dev-willbird1936 requested a review from a team as a code owner July 25, 2026 22:52
@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Jul 25, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Jul 25, 2026
@github-actions github-actions Bot added C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. labels Jul 25, 2026
@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,125 53,125 0
Passed 51,073 51,073 0
Ignored 1,482 1,482 0
Failed 570 570 0
Panics 0 0 0
Conformance 96.14% 96.14% 0.00%

Tested main commit: 4fc75c6ae9d85f2b8065c6716f88e9b35318438c
Tested PR commit: 5a469a6b4583d8a0479ee95514b2fd364157b292
Compare commits: 4fc75c6...5a469a6

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.93%. Comparing base (6ddc2b4) to head (5a469a6).
⚠️ Report is 1012 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5457       +/-   ##
===========================================
+ Coverage   47.24%   62.93%   +15.68%     
===========================================
  Files         476      530       +54     
  Lines       46892    59119    +12227     
===========================================
+ Hits        22154    37205    +15051     
+ Misses      24738    21914     -2824     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Register forwarding can reread a mutable left operand after right-side effects

2 participants