Skip to content

fix(transformer): correct symbol flags for lowered enums#24269

Merged
graphite-app[bot] merged 1 commit into
mainfrom
transformer-enum-flags-immediate
Jul 7, 2026
Merged

fix(transformer): correct symbol flags for lowered enums#24269
graphite-app[bot] merged 1 commit into
mainfrom
transformer-enum-flags-immediate

Conversation

@Dunqing

@Dunqing Dunqing commented Jul 7, 2026

Copy link
Copy Markdown
Member

Closes #24226 — the first commit is @camc314's fix from there.

Lowered enums kept their RegularEnum/ConstEnum symbol flags, so the flags no longer matched the emitted JavaScript:

  • Top-level enums become varFunctionScopedVariable.
  • Exported and nested enums become letBlockScopedVariable.
  • Merged enums lowered to an assignment only lose their enum bits.

This removes over 1,000 stale symbol-flag mismatches from the snapshots.

Unlike #24226 there is no pending state: enum member inlining now identifies enums through EnumData (#24268) instead of SymbolFlags, so the flags can be updated right when the enum is lowered.

@github-actions github-actions Bot added the A-transformer Area - Transformer / Transpiler label Jul 7, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 52 untouched benchmarks
⏩ 19 skipped benchmarks1


Comparing transformer-enum-flags-immediate (84eeb55) with semantic-record-const-enums (f5a5104)2

Open in CodSpeed

Footnotes

  1. 19 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 semantic-record-const-enums (1b829d8) during the generation of this report, so 8295b04 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Dunqing
Dunqing force-pushed the transformer-enum-flags-immediate branch from 4d1f444 to f8d3de1 Compare July 7, 2026 15:26
@Dunqing
Dunqing force-pushed the semantic-record-const-enums branch from 28fd65d to 3d3b24e Compare July 7, 2026 15:26

Dunqing commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@Dunqing Dunqing changed the title refactor(transformer): set lowered enum symbol flags in place fix(transformer): correct symbol flags for lowered enums Jul 7, 2026
@Dunqing
Dunqing force-pushed the semantic-record-const-enums branch from 3d3b24e to f5a5104 Compare July 7, 2026 16:17
@Dunqing
Dunqing force-pushed the transformer-enum-flags-immediate branch from f8d3de1 to 89a3dda Compare July 7, 2026 16:17
@Dunqing
Dunqing marked this pull request as ready for review July 7, 2026 16:26
@graphite-app

graphite-app Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Merge activity

Closes #24226 — the first commit is @camc314's fix from there.

Lowered enums kept their `RegularEnum`/`ConstEnum` symbol flags, so the flags no longer matched the emitted JavaScript:

- Top-level enums become `var` → `FunctionScopedVariable`.
- Exported and nested enums become `let` → `BlockScopedVariable`.
- Merged enums lowered to an assignment only lose their enum bits.

This removes over 1,000 stale symbol-flag mismatches from the snapshots.

Unlike #24226 there is no pending state: enum member inlining now identifies enums through `EnumData` (#24268) instead of `SymbolFlags`, so the flags can be updated right when the enum is lowered.
graphite-app Bot pushed a commit that referenced this pull request Jul 7, 2026
Record which enums are `const` in `EnumData` and expose it as `Scoping::is_const_enum`. Same pattern as the existing `no_side_effects` set.

The transformer needs to tell const enums apart even after lowering, but #24269 makes lowering rewrite the enum's `SymbolFlags`, so the flags can no longer answer that. `EnumData` stays valid for the whole transform.

The small `allocs_semantic.snap` bump is the new hash set.

Needed by #24269.
@graphite-app
graphite-app Bot force-pushed the semantic-record-const-enums branch from f5a5104 to 1b829d8 Compare July 7, 2026 16:48
@graphite-app
graphite-app Bot requested a review from overlookmotel as a code owner July 7, 2026 16:48
@graphite-app
graphite-app Bot force-pushed the transformer-enum-flags-immediate branch from 89a3dda to 84eeb55 Compare July 7, 2026 16:48
Base automatically changed from semantic-record-const-enums to main July 7, 2026 16:53
@graphite-app
graphite-app Bot merged commit 84eeb55 into main Jul 7, 2026
39 checks passed
@graphite-app
graphite-app Bot deleted the transformer-enum-flags-immediate branch July 7, 2026 16:54
Boshen added a commit that referenced this pull request Jul 14, 2026
### 🚀 Features

- 616bfa2 minifier: Remove unreachable code after terminating statements
(#24441) (Dunqing)
- ddab89a data_structures: Add `likely` and `unlikely` functions
(#24368) (overlookmotel)
- a3a39f9 react_compiler: Implement enableEmitHookGuards codegen
(#24329) (Boshen)
- b79eef7 minifier: Apply De Morgan's law to negated comparison chains
in jump guards and loop tests (#24279) (Dunqing)
- 34ff7b4 minifier: Drop write-only property assignments to unused local
bindings by default (#24112) (Dunqing)
- 1b829d8 semantic: Record const enums in EnumData (#24268) (Dunqing)
- ba0944c semantic: Add `Scoping::set_symbol_span` (#24221) (camc314)

### 🐛 Bug Fixes

- 7d33363 minifier: Preserve guaranteed throws from class heritage
evaluation (#24349) (Dunqing)
- 058a62f semantic: Track ambient contexts in `SemanticBuilder` (#24327)
(camc314)
- 721eb0b transformer/decorator: Scope accessor class binding (#24330)
(camc314)
- 1ebdce3 semantic: Allow reserved keywords in ambient declaration types
(#24325) (camc314)
- 460176a track-memory-allocations: Exclude arena chunks from Sys allocs
(#24292) (Dunqing)
- af4922b transformer: Clear lowered namespace redeclarations (#24300)
(camc314)
- ffd2765 semantic: Mark declared computed `MethodDefinition`s as type
references (#24296) (camc314)
- f17514b isolated-declarations: Emit const readonly fields as types
(#24288) (camc314)
- 40f769d minifier: Make `__proto__` write tracking execution-order
independent (#24280) (Dunqing)
- 6371fed transformer: Remove stale enum member bindings (#24272)
(camc314)
- f05dfab transformer: Correct symbol flags for lowered namespaces
(#24271) (Dunqing)
- 84eeb55 transformer: Correct symbol flags for lowered enums (#24269)
(Dunqing)
- c3057da transformer: Preserve generated class binding spans (#24220)
(camc314)
- 8260096 transformer: Correct span for lowered namespace symbol
(#24222) (camc314)
- 42d00d3 semantic: Mark declared class heritage as type references
(#24237) (camc314)
- 588d997 semantic: Mark TS `PropertyDefinition`s computed fields as
type references (#24233) (camc314)
- 9b95632 semantic: Mark computed method keys in `TSMethodSignature`s as
type references (#24232) (camc314)

### ⚡ Performance

- 5b26643 transformer_plugins: Dispatch global defines by trailing name
(#23666) (Boshen)
- dce0f29 react_compiler: Replace all compiled functions in a single AST
walk (#24403) (Boshen)
- f85f0d8 ast: Delegate inherited enum variants in clone_in and estree
derives (#23555) (Boshen)
- 3ff0234 allocator: Remove `unwrap` from `ReplaceWith` (#24365)
(overlookmotel)
- ab22e80 transformer: Fix Rust 1.97 performance regression (#24354)
(camc314)
- b47585c parser: Use `ReplaceWith` instead of `TakeIn` (#24018)
(overlookmotel)
- b227a06 minifier: Use `ReplaceWith` instead of `TakeIn` (#24017)
(overlookmotel)

Co-authored-by: Boshen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants