Skip to content

x/tools/gopls: impossible type assertion failure in ChangeSignature (inliner) #76256

@adonovan

Description

@adonovan
#!stacks
"panicdottypeI" && "inline.(*state).inlineCall:+159"

Issue created by stacks.

I audited the type checker for places that construct a variadic signature, and in all cases it derives from an Ellipsis as the final element of FuncType.Params.List, so the code below is sound. I think is yet another case of random memory corruption.

	if sig.Variadic() {
			lastParam := last(params)
...				// ordinary/ellipsis call to variadic

				// simplify decl: func(T...) -> func([]T)
				lastParamField := last(calleeDecl.Type.Params.List)
				lastParamField.Type = &ast.ArrayType{
					Elt: lastParamField.Type.(*ast.Ellipsis).Elt, // panic: type assertion failed

This stack BVYdIg was reported by telemetry:

golang.org/x/tools/[email protected] go1.25.0 windows/amd64 vscode (6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/memory-corruption"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)gopls/telemetry-wins

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions