Repository navigation
fix: Fix MemberList panic on merged enum element access - #64746
Open
Andre Fajar N (andre-fajar-n) wants to merge 3 commits into
Open
Andre Fajar N (andre-fajar-n) wants to merge 3 commits into
Andre Fajar N (andre-fajar-n) wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Alias exports targeting enum members must be resolved before applying the new flag guard.
1 open finding
What changed in this PR
Prevents a compiler panic when bracket access resolves to a non-enum export on a merged enum/namespace.
Changes:
- Guards enum evaluation with
SymbolFlagsEnumMember. - Adds a regression test and diagnostic, emit, type, and symbol baselines.
| File | Description |
|---|---|
tsc/internal/checker/checker.go |
Restricts bracket-access enum evaluation. |
tsc/testdata/tests/cases/compiler/enumInitializerNamespaceExportElementAccess.ts |
Adds the crash regression case. |
tsc/testdata/baselines/reference/compiler/enumInitializerNamespaceExportElementAccess.errors.txt |
Records TS18033. |
tsc/testdata/baselines/reference/compiler/enumInitializerNamespaceExportElementAccess.js |
Records emitted JavaScript. |
tsc/testdata/baselines/reference/compiler/enumInitializerNamespaceExportElementAccess.symbols |
Records resolved symbols. |
tsc/testdata/baselines/reference/compiler/enumInitializerNamespaceExportElementAccess.types |
Records inferred types. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Jake Bailey (jakebailey)
requested review from
Wesley Wigham (weswigham)
and
a balanced review from Copilot
October 12, 2026 17:53
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #64668
AI assistance disclosure: This patch was authored with Cursor (AI coding agent). I
have read and understood the change, and I will shepherd review and revisions myself.
Analysis
When an enum and a namespace share a name, element access like
E["C"]in an enummember initializer can resolve a namespace export (e.g. a class) via
rootSymbol.Exports()[name].The element-access path in
evaluateEntitytreated any non-nil export as an enum memberand called
getEnumMemberValue→computeEnumMemberValues(node.Parent)→Members().For a class declaration,
Parentis aModuleBlock, soNode.MemberListpanicked:panic: Unhandled case in Node.MemberList: KindModuleBlockRepro:
The identifier/property-access path already requires
SymbolFlagsEnumMember; elementaccess did not.
Fix
In
evaluateEntity'sKindElementAccessExpressionbranch, only constant-evaluate whenthe export has
SymbolFlagsEnumMember(same guard as the identifier path).Non-enum-member exports fall through to a non-constant result and produce a normal
diagnostic (TS18033) instead of crashing.
Alternate considered: widening
Node.MemberListto acceptKindModuleBlock— rejected;the bug is incorrect enum evaluation, not a missing AST list case.