Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix crash in completions following call expressions#1417

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Copilot wants to merge4 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/fix-1416

Conversation

Copilot
Copy link
Contributor

@CopilotCopilotAI commentedJul 18, 2025
edited
Loading

This PR fixes a crash that occurred when requesting completions immediately after a call expression, such as:

letx=someCall()/**/

Problem

The crash was happening in thegetArgumentInfoForCompletions function when it attempted to dereferenceinfo.argumentIndex without checking if it was nil. The stack trace showed:

panic handling request textDocument/completion runtime error: invalid memory address or nil pointer dereferencegithub.com/microsoft/typescript-go/internal/ls.getArgumentInfoForCompletions(...)github.com/microsoft/typescript-go/internal/ls/completions.go:4574 +0x70

Root Cause

When the cursor is positioned after a call expression but not inside its argument list, thegetArgumentIndex function can returnnil. However,getArgumentInfoForCompletions was only checking ifinfo itself was nil, not ifinfo.argumentIndex was nil, before dereferencing it with*info.argumentIndex.

Solution

Added a nil check forinfo.argumentIndex in the condition before creating theargumentInfoForCompletions struct:

ifinfo==nil||info.isTypeParameterList||info.invocation.callInvocation==nil||info.argumentIndex==nil {returnnil}

Testing

  • Created comprehensive test cases covering different call expression completion scenarios
  • Verified that existing completion tests continue to pass
  • Confirmed the fix prevents the crash while maintaining expected completion behavior (users now get infix operator completions likesatisfies,as, etc.)

Fixes#1416.


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

…ck for argumentIndexCo-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
@CopilotCopilotAI changed the title[WIP] Crash caused by completions following callFix crash in completions following call expressionsJul 18, 2025
Copilot finished work on behalf ofDanielRosenwasserJuly 18, 2025 19:27

Choose a reason for hiding this comment

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

Convert this file into a fourslash completions test.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Converted the test to proper fourslash format using numbered markers (/*1*/,/*2*/) instead of/**/ and consolidated into a single test function with multiple marker verification. (385a152)

… with numbered markersCo-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot finished work on behalf ofDanielRosenwasserJuly 18, 2025 21:02
@DanielRosenwasser
Copy link
Member

I was wrong. Revert the last change, and then

  1. Get rid of the second test case (it's unnecessary)
  2. Move it out of thegen folder (new tests don't go there)

…ut of gen folderCo-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
@CopilotCopilot SWE Agent
Copy link
ContributorAuthor

I was wrong. Revert the last change, and then

  1. Get rid of the second test case (it's unnecessary)
    ...

Reverted the numbered markers change, removed the unnecessary second test case, and moved the test out of the gen folder as requested. (a84cdca)

@gabrittogabritto marked this pull request as ready for reviewJuly 18, 2025 23:50
@CopilotCopilotAI review requested due to automatic review settingsJuly 18, 2025 23:50
Copy link
Contributor

@CopilotCopilotAI 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 runtime panic that occurred when requesting code completions immediately after call expressions in TypeScript code. The crash was caused by attempting to dereference a nil pointer in the completion handling logic.

  • Added a nil check forinfo.argumentIndex in thegetArgumentInfoForCompletions function
  • Created comprehensive test coverage to verify the fix and prevent regression
  • Ensured users now receive appropriate infix operator completions (likesatisfies,as) instead of crashing

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

FileDescription
internal/ls/completions.goAdded nil check forinfo.argumentIndex to prevent panic when dereferencing
internal/fourslash/tests/completionAfterCallExpression_test.goAdded test case to verify completion behavior after call expressions and prevent regression
Comments suppressed due to low confidence (2)

internal/fourslash/tests/completionAfterCallExpression_test.go:16

  • Consider adding additional test cases for different call expression scenarios, such as chained calls (e.g.,obj.method()./**/) or calls with arguments (e.g.,func(arg)./**/) to ensure comprehensive coverage.
const content1 = `let x = someCall() /**/`

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@DanielRosenwasserDanielRosenwasserDanielRosenwasser approved these changes

@gabrittogabrittogabritto approved these changes

@navya9singhnavya9singhAwaiting requested review from navya9singh

At least 1 approving review is required to merge this pull request.

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Crash caused by completions following call
3 participants
@Copilot@DanielRosenwasser@gabritto

[8]ページ先頭

©2009-2025 Movatter.jp