-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/gopls: stubmethods: "could not find the enclosing function of the return statement" bug in GetIfaceStubInfo #70666
Comments
Another nonsensical backtrace. |
Change https://go.dev/cl/633375 mentions this issue: |
This CL refine an as-yet unreproducible crash into a bug report. It seems clear that the code intended to check that sig != nil, yet instead checked that sig.Results != nil. With that said, I don't think it's possible to have a return statement without an enclosing signature. For now, turn this into a bug report. For golang/go#70666 Change-Id: I79031d437d643f6d70360e3abde86166176647b3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/633375 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Change https://go.dev/cl/633715 mentions this issue: |
func fromReturnStmt(fset *token.FileSet, info *types.Info, pos token.Pos, path []ast.Node, ret *ast.ReturnStmt) (*IfaceStubInfo, error) {
// Find return operand containing pos.
returnIdx := -1
for i, r := range ret.Results {
if r.Pos() <= pos && pos <= r.End() {
returnIdx = i
break
}
}
if returnIdx == -1 {
return nil, fmt.Errorf("pos %d not within return statement bounds: [%d-%d]", pos, ret.Pos(), ret.End())
}
concType, pointer := concreteType(ret.Results[returnIdx], info)
if concType == nil || concType.Obj().Pkg() == nil {
return nil, nil // result is not a named or *named or alias thereof
}
// Inv: the return is not a spread return,
// such as "return f()" where f() has tuple type.
conc := concType.Obj()
if conc.Parent() != conc.Pkg().Scope() {
return nil, fmt.Errorf("local type %q cannot be stubbed", conc.Name())
}
sig := typesutil.EnclosingSignature(path, info) // this is L0284
... @prattmic Notice that all the lines matching L0284--the call to EnclosingSignature, which is not in the telemetry stack trace--are only loads from stack slots and the CALL itself: nothing really fallible.
|
One possibility: there is an enclosing Func{Decl,Lit}, but the type checker has failed to record an Info.{Defs,Types} for it. |
Issue created by stacks.
This stack
P5n9hA
was reported by telemetry:crash/crash
runtime.gopanic:+69
runtime.panicmem:=262
runtime.sigpanic:+19
golang.org/x/tools/gopls/internal/golang/stubmethods.fromReturnStmt:+24
golang.org/x/tools/gopls/internal/golang/stubmethods.GetIfaceStubInfo:+10
golang.org/x/tools/gopls/internal/golang.quickFix:+44
golang.org/x/tools/gopls/internal/golang.CodeActions:+65
golang.org/x/tools/gopls/internal/server.(*server).CodeAction:+154
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+160
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
Dups: fm8UdQ
The text was updated successfully, but these errors were encountered: