Open adonovan opened 2 months ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
I can't explain this one. The only three calls to recordDef(id, nil)
in the type checker are for:
package id
switch id := expr.(type) {}
_ = expr
.It can't be (1) because the Hover logic handled the package clause specially at L186. It can't be (2) because this would cause referencedObject to return a non-nil third result (selectedType), causing an early return. And it can't be (3) because that would cause referencedObject not to return a non-nil Object, Ident pair, leading to an early return.
Clearly there is a mistake in my logic. But where?
Agreed. I think the best we'll be able to do here is downgrade the panic into two or more bug reports that refine the panic.
This is not the first "can't happen" bug related to go/types...
Change https://go.dev/cl/627015 mentions this issue: gopls/internal/golang: refine crash report golang/go#69362
This stack
zUGLQA
was reported by telemetry:Looks like
Defs[ident]=nil
is an actual map entry.crash/crash
runtime.gopanic:+69
runtime.panicmem:=262
runtime.sigpanic:+19
golang.org/x/tools/gopls/internal/golang.hover:+170
golang.org/x/tools/gopls/internal/golang.Hover:+4
golang.org/x/tools/gopls/internal/server.(*server).Hover:+30
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+335
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.