Skip to content

x/tools/gopls: ChangeSignature: crash in in inliner (likely due to ill-formed variadic call) #73187

Open
@adonovan

Description

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

Issue created by stacks.

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

The fix is to do something like what gopls does in gopls/internal/golang/inline.go, but in the inline package itself so that all callers (e.g. ChangeSignature) benefit:

	// The inliner assumes that input is well-typed,
	// but that is frequently not the case within gopls.
	// Until we are able to harden the inliner,
	// report panics as errors to avoid crashing the server.
	bad := func(p *cache.Package) bool { return len(p.ParseErrors())+len(p.TypeErrors()) > 0 }
	if bad(calleePkg) || bad(callerPkg) {
		defer func() {
			if x := recover(); x != nil {
				err = fmt.Errorf("inlining failed (%q), likely because inputs were ill-typed", x)
			}
		}()
	}

This stack nlN-6w was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.5 darwin/arm64 vscode (2)

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/telemetry-wins

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions