Skip to content

fix(transformer): remove unnecessary trailing expression in object rest spread assignment#19259

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix/transformer-object-rest-spread-trailing-expr
Feb 11, 2026
Merged

fix(transformer): remove unnecessary trailing expression in object rest spread assignment#19259
graphite-app[bot] merged 1 commit intomainfrom
fix/transformer-object-rest-spread-trailing-expr

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Feb 11, 2026

Summary

  • Skip the trailing reference (e.g. _c) in the generated sequence expression when the destructuring assignment is directly inside an ExpressionStatement, since the expression result is not consumed
  • Before: _c = c2, {a2} = _c, b2 = objectWithoutProperties(_c, ["a2"]), _c;
  • After: _c = c2, {a2} = _c, b2 = objectWithoutProperties(_c, ["a2"]);
  • The trailing reference is still kept when the result is consumed, e.g. console.log((..., _c))

Closes #7389 (issue 1)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 11, 2026 11:31
@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-bug Category - Bug labels Feb 11, 2026
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Feb 11, 2026
Copy link
Member Author

Boshen commented Feb 11, 2026

Merge activity

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request optimizes the object rest spread transformer by removing unnecessary trailing reference expressions in sequence expressions when the destructuring assignment result is not consumed.

Changes:

  • Modified object_rest_spread.rs to detect when an assignment expression is directly inside an ExpressionStatement (ignoring parenthesized wrappers)
  • When the result is not consumed, the trailing reference is omitted from the generated sequence expression
  • Updated test fixture outputs to reflect the optimized transformation

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_transformer/src/es2018/object_rest_spread.rs Added logic to check ancestor chain and conditionally omit trailing reference when expression result is not consumed
tasks/transform_conformance/tests/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/assignment-expression/output.js Updated expected output to remove trailing reference in line 3
tasks/transform_conformance/overrides/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/assignment-expression/output.js Updated expected output to remove trailing reference in line 3
tasks/transform_conformance/overrides/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/impure-computed/output.js Updated expected output to remove trailing reference in line 22
tasks/transform_conformance/overrides/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/template-literal-allLiterals-true-no-hoisting/output.js Updated expected output to remove trailing reference in line 5
tasks/transform_conformance/snapshots/babel.snap.md Updated snapshots showing improvements in symbol table accuracy (fewer binding/scope mismatches)

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will degrade performance by 4.02%

❌ 3 regressed benchmarks
✅ 44 untouched benchmarks
⏩ 3 skipped benchmarks1

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

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation transformer[binder.ts] 1.6 ms 1.6 ms -4.02%
Simulation transformer[react.development.js] 682.8 µs 707.8 µs -3.52%
Simulation transformer[cal.com.tsx] 25.8 ms 26.7 ms -3.64%

Comparing fix/transformer-object-rest-spread-trailing-expr (2358438) with main (740a009)2

Open in CodSpeed

Footnotes

  1. 3 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.

  2. No successful run was found on main (9195430) during the generation of this report, so 740a009 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

graphite-app bot pushed a commit that referenced this pull request Feb 11, 2026
…st spread assignment (#19259)

## Summary

- Skip the trailing reference (e.g. `_c`) in the generated sequence expression when the destructuring assignment is directly inside an `ExpressionStatement`, since the expression result is not consumed
- Before: `_c = c2, {a2} = _c, b2 = objectWithoutProperties(_c, ["a2"]), _c;`
- After: `_c = c2, {a2} = _c, b2 = objectWithoutProperties(_c, ["a2"]);`
- The trailing reference is still kept when the result is consumed, e.g. `console.log((..., _c))`

Closes #7389 (issue 1)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app graphite-app bot force-pushed the fix/transformer-object-rest-spread-trailing-expr branch from 2358438 to 0175bc2 Compare February 11, 2026 11:41
…st spread assignment (#19259)

## Summary

- Skip the trailing reference (e.g. `_c`) in the generated sequence expression when the destructuring assignment is directly inside an `ExpressionStatement`, since the expression result is not consumed
- Before: `_c = c2, {a2} = _c, b2 = objectWithoutProperties(_c, ["a2"]), _c;`
- After: `_c = c2, {a2} = _c, b2 = objectWithoutProperties(_c, ["a2"]);`
- The trailing reference is still kept when the result is consumed, e.g. `console.log((..., _c))`

Closes #7389 (issue 1)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app graphite-app bot force-pushed the fix/transformer-object-rest-spread-trailing-expr branch from 0175bc2 to deed3d8 Compare February 11, 2026 11:43
@graphite-app graphite-app bot merged commit deed3d8 into main Feb 11, 2026
21 checks passed
@graphite-app graphite-app bot deleted the fix/transformer-object-rest-spread-trailing-expr branch February 11, 2026 11:49
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 11, 2026
camc314 pushed a commit that referenced this pull request Feb 16, 2026
### 🚀 Features

- 429d876 semantic: Assign ast node ids during semantic build (#19263)
(Boshen)
- ebb80b3 ast: Add `node_id` field to all AST struct nodes (#18138)
(Boshen)

### 🐛 Bug Fixes

- bfb15a3 semantic: Make multi_index_vec clone panic-safe (#19299)
(Boshen)
- 41c50a5 transformer: Ignore invalid JSX pragma identifiers (#19296)
(Boshen)
- deed3d8 transformer: Remove unnecessary trailing expression in object
rest spread assignment (#19259) (Boshen)
- 5bdaacc transformer: Propagate source spans for sourcemap correctness
(#19258) (Boshen)
- 3e0e5ba isolated-declarations: Align readonly class array initializer
diagnostics with tsc (#19218) (camc314)

### ⚡ Performance

- c169c77 syntax: Optimize `is_identifier_name_patched` (#19386)
(sapphi-red)
- aa1e1a8 allocator: Inline BitSet accessors (#19331) (Boshen)
- 5b90d46 semantic: Improve SoA with multi index vec (#19138) (Boshen)
- 99ce2a6 isolated_declarations: Mark all diagnostic functions as
`#[cold]` (#19279) (camc314)
- dd0220f transformer: Remove TS-only nodes earlier in
`enter_statements` (#19166) (Dunqing)
- e5baf60 isolated-declarations: Replace hash collections with
index-based Vec (#19221) (Dunqing)

### 📚 Documentation

- 569aa61 rust: Add missing rustdocs and remove missing_docs lint attrs
(#19306) (Boshen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transformer: object rest spread remaining issues

2 participants