Repository navigation
fix: Fix nil pointer panic in getLateBoundSymbol under --noCheck - #64731
Open
Andre Fajar N (andre-fajar-n) wants to merge 1 commit into
Open
Andre Fajar N (andre-fajar-n) wants to merge 1 commit into
Andre Fajar N (andre-fajar-n) wants to merge 1 commit into
Conversation
Copilot started reviewing on behalf of
Andre Fajar N (andre-fajar-n)
October 11, 2026 03:45
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The targeted nil guard resolves the reported panic and is covered by an appropriate compiler regression test.
0 open findings
What changed in this PR
Fixes a nil-pointer panic during declaration-only emit with --noCheck for top-level computed expando assignments.
Changes:
- Guards late binding when the symbol parent is nil.
- Adds a compiler regression test and output baselines.
| File | Description |
|---|---|
tsc/internal/checker/checker.go |
Prevents dereferencing a nil parent during late binding. |
tsc/testdata/tests/cases/compiler/noCheckExpandoElementAccessAssignment.ts |
Adds the regression case. |
tsc/testdata/baselines/reference/compiler/noCheckExpandoElementAccessAssignment.js |
Captures declaration emit. |
tsc/testdata/baselines/reference/compiler/noCheckExpandoElementAccessAssignment.symbols |
Captures symbol output. |
tsc/testdata/baselines/reference/compiler/noCheckExpandoElementAccessAssignment.types |
Captures inferred types. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Author
|
@microsoft-github-policy-service agree |
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 #64669
Analysis
With
--declaration --emitDeclarationOnly --noCheck, declaration emit can force late binding for a computed expando assignmentlike:
In that path,
getLateBoundSymbolcallsgetMembersOfSymbol/getExportsOfSymbolon the symbol's parent. For a top-levelscript, the parent can be nil (the SourceFile has no symbol), which panics:
panic: runtime error: invalid memory address or nil pointer dereferenceWithout
--noCheck, checking usually late-binds earlier, so the nil parent path is less likely to be hit.Fix
Guard on a non-nil parent before forcing late binding in
getLateBoundSymbol. If the parent is nil, fall through to the existinglateSymbol = symbolfallback instead of dereferencing nil.Added compiler test
noCheckExpandoElementAccessAssignmentcovering this flags + repro combination.Notes
AI-assisted change (Cursor); I reviewed and verified the patch locally against the repro and the new harness test.