Skip to content

fix(transformer): legacy decorator on computed property key leaves variable unassigned#20430

Merged
Dunqing merged 4 commits intooxc-project:mainfrom
babu-ch:fix/legacy-decorator-computed-key-unassigned
Mar 17, 2026
Merged

fix(transformer): legacy decorator on computed property key leaves variable unassigned#20430
Dunqing merged 4 commits intooxc-project:mainfrom
babu-ch:fix/legacy-decorator-computed-key-unassigned

Conversation

@babu-ch
Copy link
Contributor

@babu-ch babu-ch commented Mar 16, 2026

This PR has two fixes. The second fix exposed a pre-existing bug that needed to be fixed first.

  • 24a72d7: create_read_write_target was used for a simple = assignment when creating a temp var for decorated computed property keys. Should be create_write_target.

  • f0affc6: transform_class_on_exit was removing all no-initializer properties unconditionally. But the legacy decorator embeds an assignment in the computed key ([FIELD_NAME][_a = FIELD_NAME]), so removing the property also removes the assignment, leaving _a undefined in _decorate(). Keep properties whose computed keys have side effects, matching TypeScript's
    behavior.

Fixes #20418

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-bug Category - Bug labels Mar 16, 2026
Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Good job!

@Dunqing Dunqing force-pushed the fix/legacy-decorator-computed-key-unassigned branch from 4b5b9b8 to bd8d52f Compare March 17, 2026 15:04
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 17, 2026

Merging this PR will not alter performance

✅ 49 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing babu-ch:fix/legacy-decorator-computed-key-unassigned (4453f59) with main (efeba28)

Open in CodSpeed

Footnotes

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

@Dunqing Dunqing merged commit 11f9695 into oxc-project:main Mar 17, 2026
28 checks passed
@babu-ch babu-ch deleted the fix/legacy-decorator-computed-key-unassigned branch March 18, 2026 03:43
Boshen added a commit that referenced this pull request Mar 19, 2026
### 🚀 Features

- 7215d9e transformer: Support lowering `accessor` with legacy
decorators (#20348) (Dunqing)

### 🐛 Bug Fixes

- 3bbd0cd transformer: Emit `Object` instead of `void 0` for untyped
getter/setter `design:type` metadata (#20488) (Dunqing)
- 4ae3f3f ecmascript: Apply coercion-is-pure assumption to constructor
side-effect detection (#20420) (Dunqing)
- 11f9695 transformer: Legacy decorator on computed property key leaves
variable unassigned (#20430) (bab)
- efeba28 ecmascript: Add argument validation for NewExpression
side-effect detection (#20395) (Dunqing)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
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: legacy decorator on computed property key: variable declared but not assigned

2 participants