Registry Mirror
Skip to content

Conversation

@jakebailey

Copy link
Copy Markdown
Member

allocNodeSlice returns an empty slice with the requested cap, so needs to be appended to, not assigned to.

API clients can send printNode and formatNodeForInsertion a tree
containing a JSDocTypeLiteral with property tags or a SyntaxList with
children. Decoding either panicked: the generated decoder reserves
capacity for these raw child lists, then indexes into them as though
they already had that length.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the raw AST child-list decoding fix.

No open issues 🎉

1 file not reviewed
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
What changed in this PR

Fixes raw AST child-list decoding in the Go API decoder by appending into reserved slice storage, avoiding out-of-range writes to zero-length slices.

Changes:

  • Updates the decoder generator and generated handling for SyntaxList and JSDocTypeLiteral.
  • Adds regression tests for empty, single-child, and multi-child lists, checking child order, scalar data, and encoding round trips.
File Description
tsc/​internal/​api/​encoder/​decoder_test.go Adds raw child-list decoding regression tests.
tsc/​internal/​api/​encoder/​decoder_generated.go Replaces indexed writes with appends for both affected node kinds.
tools/​scripts/​tsc/​generate-encoder.ts Preserves the append-based fix during regeneration.

Review effort: Balanced

@weswigham Wesley Wigham (weswigham) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm guessing the difference is in len results, unlike in js where these'd be identical.

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Dec 1, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Dec 1, 2026
Merged via the queue into microsoft:main with commit 2659683 Dec 1, 2026
34 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the compiler-fixes/ast-decoding branch December 1, 2026 19:36
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants