Closed
Description
#!stacks
"runtime.goPanicIndex" && "go/types.(*Tuple).At" && "completion.expectedReturnStmtType"
Issue created by stacks.
// expectedReturnStmtType returns the expected type of a return statement.
// Returns nil if enclosingSig is nil.
func expectedReturnStmtType(enclosingSig *types.Signature, node *ast.ReturnStmt, pos token.Pos) types.Type {
if enclosingSig != nil {
if resultIdx := exprAtPos(pos, node.Results); resultIdx < len(node.Results) {
return enclosingSig.Results().At(resultIdx).Type() // <--- At panics
}
}
return nil
}
This stack 69yMYw
was reported by telemetry:
crash/crash
runtime.gopanic:+69
runtime.goPanicIndex:+2
go/types.(*Tuple).At:=34
golang.org/x/tools/gopls/internal/golang/completion.expectedReturnStmtType:+3
golang.org/x/tools/gopls/internal/golang/completion.expectedCandidate:+37
golang.org/x/tools/gopls/internal/golang/completion.Completion:+150
golang.org/x/tools/gopls/internal/server.(*server).Completion:+19
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+193
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
golang.org/x/tools/gopls@v0.17.0-pre.3 go1.23.2 linux/amd64 other,vscode (5)
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
adonovan commentedon Dec 2, 2024
Closely related to #70634.
gabyhelp commentedon Dec 2, 2024
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
findleyr commentedon Dec 2, 2024
This is indeed a logic bug, as described in #70634 (comment).
gopherbot commentedon Dec 2, 2024
Change https://go.dev/cl/632936 mentions this issue:
gopls/internal/golang/completion: fix crash with extra results
1 remaining item
gopherbot commentedon Dec 4, 2024
Change https://go.dev/cl/633706 mentions this issue:
gopls/internal/golang/completion: fix crash with extra results