Skip to content

Fix panic when @callback/@overload @param has a qualified name#3922

Open
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-qualified-name-panic
Open

Fix panic when @callback/@overload @param has a qualified name#3922
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-qualified-name-panic

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

The reparser was converting all JSDoc @param tags to ParameterDeclarations when reparsing @callback/@overload signatures, including sub-property params like @param x.y which have QualifiedNames. A ParameterDeclaration should never have a QualifiedName as its name (TypeScript types it as Identifier | BindingPattern). This caused a panic when checkCollisionsForDeclarationName eventually called Node.Text() on the QualifiedName, which doesn't handle that type.

/**
 * @callback cb
 * @param x.y
 */

Analysis

In TypeScript, JSDoc callback params remain as JSDocParameterTags in a JSDocSignature, so the checker never sees ParameterDeclarations with QualifiedNames. In Corsa's reparser (internal/parser/reparser.go), all JSDoc params were being converted to ParameterDeclarations—including sub-property params like @param x.y. These sub-property params describe properties of a parent parameter, not standalone parameters, and should not become ParameterDeclarations.

Fix

  • Skip JSDoc parameters with QualifiedNames in the reparser when creating ParameterDeclarations from JSDoc callback/overload signatures
  • Add compiler test case reproducing the crash, including both @callback and @overload scenarios with qualified params

Copilot Checklist

I successfully ran these commands at the end of my session, and they completed without error:

  • npx hereby build
  • npx hereby test
  • npx hereby lint
  • npx hereby format

Guard needCollisionCheckForIdentifier against non-Identifier nodes
(e.g., QualifiedName from @param x.y) to match TypeScript's behavior
where the function only accepts Identifier | undefined.

Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/435989fa-39a8-4d7a-aeca-6166b6e55db8

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix panic when @callback/@overload @param has a qualified name Fix panic when @callback/@overload @param has a qualified name May 16, 2026
Copilot AI requested a review from jakebailey May 16, 2026 19:57
Comment thread internal/checker/checker.go
…clarations

Sub-property JSDoc params like @param x.y have QualifiedNames and
describe properties of a parent parameter, not standalone parameters.
The reparser should skip these instead of creating ParameterDeclarations
with QualifiedNames, which is the root cause of the panic.

Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/6da36b57-11b5-459e-a9e2-b5a1b47f5943

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI requested a review from jakebailey May 16, 2026 20:44
@jakebailey jakebailey marked this pull request as ready for review May 16, 2026 20:44
Copilot AI review requested due to automatic review settings May 16, 2026 20:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a JSDoc reparser crash by avoiding creation of invalid ParameterDeclaration nodes for qualified @param names in callback/overload signatures.

Changes:

  • Skips qualified JSDoc parameter names when reparsing signatures.
  • Adds a compiler regression test for qualified @param names in callbacks.
  • Adds reference symbols/types baselines for the new test.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
internal/parser/reparser.go Skips qualified JSDoc parameter names during signature reparsing.
testdata/tests/cases/compiler/jsdocCallbackParamQualifiedName.ts Adds regression coverage for qualified callback params.
testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.symbols Adds symbols baseline for the new test.
testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.types Adds types baseline for the new test.

Comment on lines +6 to +15
/**
* @callback cb
* @param x.y
*/

/**
* @callback cb2
* @param {object} x
* @param {string} x.y
*/
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.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an @overload test case with a qualified @param x.y in dac3328.

Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/9169ebac-be22-4565-a138-50bf451ec3bd

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI requested a review from jakebailey May 16, 2026 21:19
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.

tsgo panics when a @callback / @overload @param has a qualified name

3 participants