Skip to content

Conversation

@hayes
Copy link
Contributor

@hayes hayes commented Oct 28, 2025

fixes #85474

Previously, the analyzer treated all assignment expressions the same way, evaluating them as their right-hand side value. This was incorrect for compound assignments (+=, -=, *=, |=, >>=, etc.), which compute a new value based on both the left and right operands.

This commit distinguishes between simple assignments (=) and compound assignments. Simple assignments continue to evaluate to the right-hand side, while compound assignments are now properly marked as unknown values with side effects.

Also adds tests for compound assignments in conditionals, covering bitshift operations (>>=, <<=, >>>=) and bitwise operations (|=, &=, ^=) with both numbers and bigints.

Previously, the analyzer treated all assignment expressions the same way,
evaluating them as their right-hand side value. This was incorrect for
compound assignments (+=, -=, *=, |=, >>=, etc.), which compute a new
value based on both the left and right operands.

This commit distinguishes between simple assignments (=) and compound
assignments. Simple assignments continue to evaluate to the right-hand
side, while compound assignments are now properly marked as unknown
values with side effects.

Also adds tests for compound assignments in conditionals, covering
bitshift operations (>>=, <<=, >>>=) and bitwise operations (|=, &=, ^=)
with both numbers and bigints.
@ijjk ijjk added the Turbopack Related to Turbopack with Next.js. label Oct 28, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 29, 2025

CodSpeed Performance Report

Merging #85478 will degrade performances by 7.28%

Comparing hayes:canary (f308f17) with canary (1db1762)1

Summary

❌ 1 regression
✅ 7 untouched
⏩ 12 skipped2

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
Simulation react-dom-client.development.js[full] 427.9 ms 461.5 ms -7.28%

Footnotes

  1. No successful run was found on hayes/compound-assignment (137dbec) during the generation of this report, so canary (1db1762) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 12 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Contributor

@mischnic mischnic left a comment

Choose a reason for hiding this comment

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

Thank you!

@bgw bgw changed the base branch from canary to hayes/compound-assignment October 30, 2025 22:47
@bgw bgw merged commit 021db30 into vercel:hayes/compound-assignment Oct 30, 2025
30 of 31 checks passed
@bgw
Copy link
Member

bgw commented Oct 30, 2025

FYI, @hayes I merged this into a non-fork branch to work around a CI issue we ran into (apparently the branch name "canary" on your fork was causing one of our webhooks to bail out). Running CI and attempting to merge into canary from here: #85593

sokra pushed a commit that referenced this pull request Oct 31, 2025
…5593)

Migrated from #85478 into this non-fork because we had some issues with our CI infra that should be fixed going forward: https://vercel.slack.com/archives/C04KC8A53T7/p1761862171772939 

---

fixes #85474 

Previously, the analyzer treated all assignment expressions the same way, evaluating them as their right-hand side value. This was incorrect for compound assignments (+=, -=, *=, |=, >>=, etc.), which compute a new value based on both the left and right operands.

This commit distinguishes between simple assignments (=) and compound assignments. Simple assignments continue to evaluate to the right-hand side, while compound assignments are now properly marked as unknown values with side effects.

Also adds tests for compound assignments in conditionals, covering bitshift operations (>>=, <<=, >>>=) and bitwise operations (|=, &=, ^=) with both numbers and bigints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bitshift assignement in conditional broken in turbopack

4 participants