Skip to content

Properly visit the Expression node of a TypeParameterDeclaration #865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2025

Conversation

ahejlsberg
Copy link
Member

The missing visit(v, node.Expression) caused a crash in the language service for a type parameter with an incomplete extends clause.

@Copilot Copilot AI review requested due to automatic review settings May 14, 2025 00:40
Copy link
Contributor

@Copilot 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 addresses a crash in the language service when processing a type parameter with an incomplete "extends" clause.

  • Added a visit call for the Expression node in the TypeParameterDeclaration to prevent crashes.
  • Ensured consistency in node visits by extending the pattern used in existing nodes.

@@ -2084,7 +2084,7 @@ func (f *NodeFactory) UpdateTypeParameterDeclaration(node *TypeParameterDeclarat
}

func (node *TypeParameterDeclaration) ForEachChild(v Visitor) bool {
return visitModifiers(v, node.modifiers) || visit(v, node.name) || visit(v, node.Constraint) || visit(v, node.DefaultType)
return visitModifiers(v, node.modifiers) || visit(v, node.name) || visit(v, node.Constraint) || visit(v, node.DefaultType) || visit(v, node.Expression)
Copy link
Member

Choose a reason for hiding this comment

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

I think this actually needs to come before DefaultType, given where the parser parses it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it. Now fixed.

@ahejlsberg ahejlsberg added this pull request to the merge queue May 14, 2025
Merged via the queue into main with commit 9bcca76 May 14, 2025
23 checks passed
@jakebailey jakebailey deleted the fix-unparented-node branch June 2, 2025 19:14
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.

None yet

2 participants