golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.21k stars 17.7k forks source link

x/tools/gopls: xrefs.Index panics after "can't fail" pgf.PosRange #70446

Closed adonovan closed 15 hours ago

adonovan commented 2 days ago
#!stacks
"runtime.gopanic" && "xrefs.Index.func2:+3"

Issue created by stacks.


        nodeRange := func(n ast.Node) protocol.Range {
            rng, err := pgf.PosRange(n.Pos(), n.End())
            if err != nil {
                panic(err) // can't fail                  <-- CAN FAIL
            }
            return rng
        }

This stack LDqHyA was reported by telemetry:

gabyhelp commented 2 days ago

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

gopherbot commented 16 hours ago

Change https://go.dev/cl/630675 mentions this issue: gopls/internal/crash: don't crash in xrefs on out of bound nodes