x/tools/gopls: "inline: corrupted reference %v" bug in golang.RemoveUnusedParameter
#!stacks
"bug.Errorf" && "golang.inlineAllCalls:+98"
Issue created by stacks.
// Sanity check.
if obj := refpkg.TypesInfo().ObjectOf(name); obj == nil ||
obj.Name() != origDecl.Name.Name ||
obj.Pkg() == nil ||
obj.Pkg().Path() != string(pkg.Metadata().PkgPath) {
return nil, bug.Errorf("cannot inline: corrupted reference %v", ref)
}
This stack u1wk7A was reported by telemetry:
gopls/buggolang.org/x/tools/gopls/internal/util/bug.report:+35golang.org/x/tools/gopls/internal/util/bug.Errorf:+2golang.org/x/tools/gopls/internal/golang.inlineAllCalls:+98golang.org/x/tools/gopls/internal/golang.rewriteCalls:+114golang.org/x/tools/gopls/internal/golang.RemoveUnusedParameter:+81golang.org/x/tools/gopls/internal/server.(*commandHandler).ChangeSignature.func1:+2golang.org/x/tools/gopls/internal/server.(*commandHandler).run.func2:+3golang.org/x/tools/gopls/internal/server.(*commandHandler).run:+73golang.org/x/tools/gopls/internal/server.(*commandHandler).ChangeSignature:+2golang.org/x/tools/gopls/internal/protocol/command.Dispatch:+39golang.org/x/tools/gopls/internal/server.(*server).ResolveCodeAction:+21golang.org/x/tools/gopls/internal/protocol.serverDispatch:+46golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
golang.org/x/tools/[email protected] go1.22.2 darwin/arm64 vscode (1)
Related Issues and Documentation
- x/tools/gopls: "unexpected files in command-line-arguments package" bug (via telemetry) #64557
- x/tools/gopls: bug: load.go:185: go/packages returned unexpected package "golang.org/x/tools/go/callgraph/cha/testdata/iface.go.~master~" for standalone file #69331
- x/tools/gopls: rename crashes in objectpath #60789 (closed)
- x/tools/gopls: crash when renaming in a package using builtins with type parameters #52940 (closed)
- x/tools/gopls: SignatureHelp bug reported by telemetry [_mSPWg] #64234 (closed)
- internal/refactor/inline: "args/params mismatch" panic (reported by telemetry) #64558 (closed)
- x/tools/gopls: call to unexpected built-in type string (*types.TypeName) #65304 (closed)
- x/tools/gopls: automated issue report (crash) #40449 (closed)
- x/tools/gopls: crash in packageReferences (reported by telemetry) #66250 (closed)
- x/tools/gopls: crash in Hover (telemetry) #69362
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
The failing assertion checks that each reference to the function or method of interest is a call to to a symbol with the same name and package as the original function. But the References algorithm returns implicit matches by joining with the "implements" relation, and these matches may come from arbitrary packages. So I think the assertion is overly strict.
Thanks, that was indeed it, and I was able to reproduce.
Fix incoming.
Change https://go.dev/cl/628376 mentions this issue: gopls/internal/golang: don't try to inline dynamic calls
This stack vmzEcA was reported by telemetry:
gopls/buggolang.org/x/tools/gopls/internal/util/bug.report:+35golang.org/x/tools/gopls/internal/util/bug.Errorf:+2golang.org/x/tools/gopls/internal/golang.inlineAllCalls:+98golang.org/x/tools/gopls/internal/golang.rewriteCalls:+114golang.org/x/tools/gopls/internal/golang.RemoveUnusedParameter:+81golang.org/x/tools/gopls/internal/server.(*commandHandler).ChangeSignature.func1:+2golang.org/x/tools/gopls/internal/server.(*commandHandler).run.func2:+3golang.org/x/tools/gopls/internal/server.(*commandHandler).run:+73golang.org/x/tools/gopls/internal/server.(*commandHandler).ChangeSignature:+2golang.org/x/tools/gopls/internal/protocol/command.Dispatch:+39golang.org/x/tools/gopls/internal/server.(*server).ResolveCodeAction:+21golang.org/x/tools/gopls/internal/protocol.serverDispatch:+46golang.org/x/tools/gopls/internal/protocol.ServerHandler.func1:+5golang.org/x/tools/gopls/internal/lsprpc.handshaker.func1:+52golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1:+2golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2:+3
golang.org/x/tools/[email protected] go1.20.7 darwin/arm64 vscode (1)