fix(transformer): correct symbol flags for lowered enums#24226
Conversation
bb60d68 to
3c4319a
Compare
fb50394 to
5bd386f
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
5bd386f to
3e0e6ad
Compare
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
Synchronizes semantic SymbolFlags with the JavaScript output produced when lowering TypeScript enums in oxc_transformer, reducing semantic/transform conformance noise from stale enum flags.
Changes:
- Defers enum symbol-flag updates until
exit_program, so enum inlining/removal can still detect enums during traversal. - Updates lowered enum symbols to
FunctionScopedVariable(top-level) orBlockScopedVariable(exported/nested), and strips enum flags when a merged enum lowers to an assignment while preserving any existing runtime-declaration flags. - Refreshes transformer/semantic snapshots and allocation tracking to reflect the corrected scoping metadata.
Reviewed changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/transform_conformance/snapshots/oxc.snap.md | Snapshot updates removing many enum-related symbol-flag mismatches. |
| tasks/transform_conformance/snapshots/babel.snap.md | Snapshot updates removing enum-related symbol-flag mismatches in Babel suite. |
| tasks/track_memory_allocations/allocs_transformer.snap | Allocation snapshot updated (small deltas) due to transformer changes. |
| tasks/coverage/snapshots/semantic_typescript.snap | Semantic snapshot updates removing enum-related symbol-flag mismatches. |
| tasks/coverage/snapshots/semantic_misc.snap | Semantic snapshot updates removing enum-related symbol-flag mismatches in misc suite. |
| tasks/coverage/snapshots/semantic_babel.snap | Semantic snapshot updates removing enum-related symbol-flag mismatches in Babel semantic suite. |
| crates/oxc_transformer/src/typescript/mod.rs | Applies deferred enum symbol-flag changes at program exit. |
| crates/oxc_transformer/src/typescript/enum.rs | Collects and applies pending enum symbol-flag updates consistent with emitted JS. |
3c4319a to
8144154
Compare
3e0e6ad to
d6c8134
Compare
8144154 to
9ae1a3c
Compare
d6c8134 to
296e712
Compare
9ae1a3c to
4f4364b
Compare
4f4364b to
7f5ea01
Compare
296e712 to
26882e6
Compare

Summary
Synchronize semantic symbol flags with the JavaScript emitted when lowering TypeScript enums.
This removes over 1,000 stale symbol-flag mismatches from semantic and transform-conformance snapshots.
Why Pending?
We delay it because
SymbolFlags::RegularEnum/ConstEnumis still analysis input for the rest of traversal.For example:
Eis lowered whenenter_statementvisits the enum. Later,enter_expressionvisitsE.Aand checks the symbol flags to recognize and inline the enum member.If lowering immediately changed
EtoFunctionScopedVariable,E.Awould no longer be recognized as an enum, so the optimization would be skipped.Thus the flags temporarily serve two roles:
var,let, or a merged declaration).Applying pending flags in
exit_programupdates them only after all enum-aware analysis is finished. It does not strictly need to be “at the end” if we introduced separate original/final flag storage, but with one sharedSymbolFlagsvalue, deferral is the simplest correct approach.