#!stacks
"goPanicIndex" && "fingerprint.unify.func3:+8"

Issue created by stacks.

func unify(x, y sexpr) bool {

    // maxTypeParam returns the maximum type parameter index in x.
    var maxTypeParam func(x sexpr) int
    maxTypeParam = func(x sexpr) int {...}
...
    yBindings := make([]*sexpr, maxTypeParam(y)+1)
    for i := range len(yBindings) {
        yBindings[i] = new(sexpr)
    }

    // bind sets binding b to s from bindings if it does not occur in s.
    bind := func(b *sexpr, s sexpr, bindings []*sexpr) bool {
...
    var uni func(x, y sexpr) bool
    uni = func(x, y sexpr) bool {
        var bx, by *sexpr
        ix := typeParamIndex(x)
        if ix >= 0 {
            bx = xBindings[ix]
        }
        iy := typeParamIndex(y)
        if iy >= 0 {
            by = yBindings[iy] // OOB index panic

This stack FSaUqg was reported by telemetry:

golang.org/x/tools/gopls@v0.20.0 go1.24.6 linux/amd64 vscode (1)

Comment From: gabyhelp

Related Issues

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

Comment From: jba

This is provably impossible (though obviously not).

yBindings has length maxTypeParam(y) + 1 (https://go.googlesource.com/tools/+/refs/tags/v0.37.0/gopls/internal/util/fingerprint/fingerprint.go#365)

maxTypeParam walks its argument completely to compute the max (https://go.googlesource.com/tools/+/refs/tags/v0.37.0/gopls/internal/util/fingerprint/fingerprint.go#348)

uni is always called with its y argument equal to the outer y or a part thereof (https://go.googlesource.com/tools/+/refs/tags/v0.37.0/gopls/internal/util/fingerprint/fingerprint.go#392 plus call sites)

yBindings is never changed.

Comment From: jba

Can I see the panic message?

Comment From: adonovan

This is provably impossible (though obviously not).

I expected that would be the case. I think this is just another case of the the memory corruption issue.

Can I see the panic message?

No. Telemetry doesn't include it, since it may application data, and thus PII.