Skip to content
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

x/tools/gopls: completion: failed type assertion in inferExpectedTypeArg #70889

Closed
adonovan opened this issue Dec 17, 2024 · 5 comments
Closed
Assignees
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Dec 17, 2024

#!stacks
"panicdottypeI" && "inferExpectedTypeArg:+11"

Issue created by stacks.

	// Infer the type parameters in a function call based on it's context
	sig := c.pkg.TypesInfo().Types[callNode.Fun].Type.(*types.Signature) // <--- panic here
	expectedResults := inferExpectedResultTypes(c, callNodeIdx)
	if typeParamIdx < 0 || typeParamIdx >= sig.TypeParams().Len() {
		return nil
	}

This stack w_8rjA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.4 darwin/amd64 vscode (1)

Dups: brclNw

@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Dec 17, 2024
@gopherbot gopherbot added this to the Unreleased milestone Dec 17, 2024
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.18.0 Dec 17, 2024
@findleyr
Copy link
Member

Hmm, we may want to consider this for a v0.17.1.

@findleyr findleyr self-assigned this Dec 18, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/637635 mentions this issue: gopls/internal/golang/completion: fix crash in instance conversion

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/637675 mentions this issue: [gopls-release-branch.0.17] gopls/internal/golang/completion: fix crash in instance conversion

gopherbot pushed a commit to golang/tools that referenced this issue Dec 19, 2024
…sh in instance conversion

The new inference logic assumed that a CallExpr surrounding an instance
was a function, but it could be a conversion, builtin, or invalid type.
Add the missing check.

Fixes golang/go#70889

Change-Id: I0b05a90cca671196cf5cfd8782b6863e17485cc1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/637635
Reviewed-by: Alan Donovan <[email protected]>
Auto-Submit: Robert Findley <[email protected]>
Commit-Queue: Robert Findley <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
(cherry picked from commit 74dea82)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/637675
@findleyr findleyr modified the milestones: gopls/v0.18.0, gopls/v0.17.1 Dec 19, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Dec 26, 2024
0.17.1

This release fixes two crashes in [email protected]:

golang/go#70889: a crash in completion of type instances inside a type conversion (found via telemetry).
golang/go#70927: a crash when a test file has a declaration with signature func(*error).

0.17.0

This release includes a variety of new features, bug fixes, and
performance improvements. It is also the first version of gopls to
require the latest released version of the Go toolchain, which
should be downloaded transparently during the gopls installation
process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants