fix(transformer): correct symbol flags for lowered namespaces#24224
fix(transformer): correct symbol flags for lowered namespaces#24224camc314 wants to merge 1 commit into
Conversation
9f52cc0 to
da679cb
Compare
0f0ea8d to
b59430b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f52cc0bb0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
da679cb to
2126502
Compare
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. |
2126502 to
13cc094
Compare
There was a problem hiding this comment.
Pull request overview
Adjusts the TypeScript namespace lowering transform so semantic SymbolFlags for namespace identifiers are corrected after the transform, reducing semantic “after transform vs rebuilt” mismatches in transformer/semantic conformance snapshots.
Changes:
- Track namespace-related
SymbolFlagsupdates during lowering and apply them after rewriting the program body. - Update namespace lowering to clear
ValueModule/NamespaceModuleflags when a namespace is treated as a redeclaration, and to forceBlockScopedVariablefor the emitted binding when it is not. - Refresh transformer/semantic conformance snapshots reflecting improved pass counts and updated mismatch output.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_transformer/src/typescript/namespace.rs | Defers and applies namespace symbol-flag adjustments after lowering, updating how redeclarations and emitted bindings are flagged. |
| tasks/transform_conformance/snapshots/oxc.snap.md | Updates transform conformance snapshot output after the namespace flag change. |
| tasks/transform_conformance/snapshots/babel.snap.md | Updates Babel fixture transform conformance snapshot counts/output. |
| tasks/coverage/snapshots/semantic_typescript.snap | Updates TypeScript semantic coverage snapshot counts/output. |
| tasks/coverage/snapshots/semantic_babel.snap | Updates Babel semantic coverage snapshot counts/output. |
13cc094 to
bb60d68
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb60d68fcf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
bb60d68 to
3c4319a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c4319af35
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| *self.pending_symbol_flags_mut(binding.symbol_id, SymbolFlags::BlockScopedVariable) = | ||
| SymbolFlags::BlockScopedVariable; |
There was a problem hiding this comment.
Preserve RegularEnum before enum optimization
When a namespace comes before an enum it merges with (namespace Foo { ... } enum Foo { A = 1 }) and optimizeEnums is enabled, this branch records Foo as only BlockScopedVariable. apply_pending_symbol_flags runs in enter_program before the traversal reaches TypeScriptEnum::enter_expression, and that inliner gates on flags.contains(SymbolFlags::RegularEnum), so later Foo.A references stop being inlined even though they were before this change and the option asks for regular enum inlining. Delay dropping RegularEnum until after enum inlining or keep enough enum state for that pass.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This finding is real, it seems break following code
namespace Foo {
export const x = 1;
}
enum Foo {
A = 1,
}
Foo.A; // before is `1`, now is `Foo.A`
Merge activity
|
3c4319a to
8144154
Compare
9378b8f to
5553efa
Compare
8144154 to
9ae1a3c
Compare
5553efa to
c3057da
Compare
9ae1a3c to
4f4364b
Compare
4f4364b to
7f5ea01
Compare
|
@codex review again |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f5ea018c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| *self.pending_symbol_flags_mut(binding.symbol_id, SymbolFlags::BlockScopedVariable) = | ||
| SymbolFlags::BlockScopedVariable; |
There was a problem hiding this comment.
Preserve enum flags until enum optimization runs
When a value namespace is the first declaration in a merge and an enum/const enum with the same name appears later, this overwrites the merged symbol flags with only BlockScopedVariable during TypeScriptNamespace::enter_program, before TypeScriptEnum traverses the program. With optimizeEnums or optimizeConstEnums enabled, TypeScriptEnum::resolve_enum_member checks symbol_flags for RegularEnum/ConstEnum, so cases like namespace E { export const x = 1 } enum E { A = 1 } console.log(E.A) stop inlining E.A even though the enum data is still available. Please keep the enum flags available until the enum pass has run, or avoid clobbering non-namespace flags here.
Useful? React with 👍 / 👎.

Summary
Synchronize semantic symbol flags with the JavaScript emitted when lowering TypeScript namespaces.
letbindings as block-scoped variables.