Skip to content

Fix nil pointer dereference in addPropertyToElementList#3361

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-nil-pointer-dereference
Draft

Fix nil pointer dereference in addPropertyToElementList#3361
Copilot wants to merge 2 commits intomainfrom
copilot/fix-nil-pointer-dereference

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

propertySymbol.Parent can be nil for synthetic union/intersection property symbols (created by createUnionOrIntersectionProperty when value declarations differ across constituents). Accessing .Flags on it crashes during declaration emit.

  • Add nil guard for propertySymbol.Parent before accessing .Flags on lines 2321 and 2346 of nodebuilderimpl.go
  • Matches the existing defensive pattern already used in checker.go:11519 and utilities.go:707:
    if prop.Parent != nil && prop.Parent.Flags&ast.SymbolFlagsClass != 0 {
  • Add compiler test declarationEmitAccessorNilParent.ts exercising accessor property declaration emit

Prevents nil pointer dereference when accessor property symbols have nil
parent (e.g. synthetic union/intersection properties). This matches the
existing nil-check pattern used in checker.go and utilities.go.

Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/9dbc6324-847e-4f7d-a3ba-c6062af308cf

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix nil pointer dereference in NodeBuilderImpl.addPropertyToElementList Fix nil pointer dereference in addPropertyToElementList Apr 7, 2026
Copilot AI requested a review from DanielRosenwasser April 7, 2026 22:08
Copy link
Copy Markdown
Member

@DanielRosenwasser DanielRosenwasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test case doesn't seem to fail locally. Back out the changes to nodebuilderimpl, validate that it actually crashes. If it does, it is probably because of the way type/symbol baselines are generated, so find a way to turn the test case into a declaration emit test.

@DanielRosenwasser
Copy link
Copy Markdown
Member

@copilot go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nil pointer derefence in (*NodeBuilderImpl).addPropertyToElementList with --tsBuildInfoFile

2 participants