Skip to content

Fix signature help crash on parenthesized call expressions #1418

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 18, 2025

Fixed a nil pointer dereference crash that occurred when requesting signature help on parenthesized call expressions with specific trigger parameters.

Problem

The language server would crash with a nil pointer dereference when:

  1. A user had a call expression like someCall()
  2. They wrapped it in parentheses: (someCall())
  3. Signature help was triggered at specific positions with triggerCharacter: "(" and triggerKind: 2

The crash occurred in GetSignatureHelpItems at line 103 when trying to access candidateInfo.candidateInfo without first checking if candidateInfo was nil.

Root Cause

The getCandidateOrTypeInfo function can return nil when it doesn't match any of the three invocation types (callInvocation, typeArgsInvocation, contextualInvocation). However, the calling code assumed candidateInfo would never be nil and attempted to access its fields directly, causing a panic.

Solution

Added a simple nil check for candidateInfo before accessing its fields:

if candidateInfo == nil {
    // We didn't have any sig help items produced by the TS compiler.
    return nil
}

This defensive programming approach prevents the crash while maintaining existing behavior for valid cases. When candidateInfo is nil, the function now returns nil (no signature help) instead of crashing.

Testing

  • Added a test case signatureHelpParenthesizedCall that reproduces the crash scenario
  • Verified the test fails with a panic before the fix and passes after
  • Confirmed all existing signature help tests continue to pass
  • Build and formatting checks pass

Fixes #1415.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Signature help crash on parenthesized call Fix signature help crash on parenthesized call expressions Jul 18, 2025
@Copilot Copilot AI requested a review from RyanCavanaugh July 18, 2025 19:57
Copilot finished work on behalf of RyanCavanaugh July 18, 2025 19:57
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.

Signature help crash on parenthesized call
2 participants