Fix signature help crash on malformed function declarations#1536
Merged
TwitchBronBron merged 4 commits intomasterfrom Jul 18, 2025
Merged
Fix signature help crash on malformed function declarations#1536TwitchBronBron merged 4 commits intomasterfrom
TwitchBronBron merged 4 commits intomasterfrom
Conversation
Co-authored-by: TwitchBronBron <[email protected]>
Copilot
AI
changed the title
[WIP] Crash during signature help
Fix signature help crash on malformed function declarations
Jul 18, 2025
TwitchBronBron
approved these changes
Jul 18, 2025
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.
This PR fixes a crash that occurs when signature help is triggered on malformed function declarations with trailing commas but missing closing parentheses.
Issue Description
The crash happened when users were defining a function and added a comma at the end without having a closing parenthesis:
When signature help was triggered (by typing comma or opening parenthesis), the language server would crash with a
TypeError: Cannot read properties of undefined (reading 'parent').Root Cause
The crash occurred in
CallExpressionInfo.tswhen the code tried to accessexpression.parentwithout checking if it was null/undefined. For malformed function declarations, the AST parser creates partial nodes where some parent relationships might not be established, leading to null reference errors.Solution
Added comprehensive null safety checks in
CallExpressionInfo.ts:ascertainCallExpression(): Added optional chaining forexpression.parent?.findAncestor()isPositionBetweenParentheses(): Return false early ifcallExpressionis nullprocess(): Added null check before accessingcallExpression.parentgetParameterIndex(): Added safety checks for nullcallExpressionorargsTesting
Added three comprehensive test cases covering:
All existing tests continue to pass (2441 passing), ensuring no regressions were introduced.
Verification
Manual testing confirms that signature help no longer crashes on malformed code and returns an empty array gracefully instead of throwing an exception.
Fixes #1467.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.