#!stacks
"sigpanic" && "types.(*Selection).Index" && "golang.hover:+188"

Issue created by stacks.


    // When hovering over a reference to a promoted struct field,
    // show the implicitly selected intervening fields.
    cur, ok := pgf.Cursor.FindByPos(pos, pos)
    if !ok {
        return protocol.Range{}, nil, fmt.Errorf("Invalid hover position, failed to get cursor")
    }
    if obj, ok := obj.(*types.Var); ok && obj.IsField() {
        if selExpr, ok := cur.Parent().Node().(*ast.SelectorExpr); ok {
            sel := pkg.TypesInfo().Selections[selExpr]
            if len(sel.Index()) > 1 { <----- panics is sel is zero

@madelinekalil

This stack j9Y3kA was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 windows/amd64 vscode (1)

Dups: nagHbw

Comment From: adonovan

Let's cherrypick a fix for this into rc3.

Comment From: adonovan

This stack nagHbw was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.1 go1.24.3 darwin/arm64 other (1)

Comment From: gopherbot

Change https://go.dev/cl/680257 mentions this issue: gopls/internal/golang: add missing ,ok check

Comment From: gabyhelp

Related Issues

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