-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
#!stacks
"sigpanic" && "inline.escape.func1:+27"
Issue created by stacks.
This stack PHhF6w was reported by telemetry:
case *ast.SelectorExpr:
// We assume TypeOf returns non-nil.
if _, ok := info.TypeOf(e.X).Underlying().(*types.Struct); ok { <---- panic
lvalue(e.X, escapes) // &s.f on struct
}The question here is why is this panic not recovered? The stack is truncated so we can't tell whether inline.Inline was called on behalf of golang.inlineCall golang.inlineAllCalls, or gofix.(*analyzer) inlineCall. However, the first two conditionally call recover if there was a type error in the caller or callee packages, and the third doesn't run on ill-typed code. So either there is a bug in the type checker that causes it to fail to record a type, or more likely, the recover condition is too strict: perhaps the type error is in a transitive dependency. The fix in that case is to compute a "transitively error-free" predicate over packages and call recover if it is false. FWIW, the deprecated go/loader had this feature; perhaps go/packages should too (though it can be derived).
crash/crashruntime.gopanic:+69,+0x153runtime.panicmem:=262,+0x2ffruntime.sigpanic:+19,+0x2ccgolang.org/x/tools/internal/refactor/inline.escape.func1:+27,+0xb4golang.org/x/tools/internal/refactor/inline.escape.func2:+4,+0xbbgo/ast.inspector.Visit:+1,+0x37go/ast.Walk:+1,+0x43go/ast.Walk:+102,+0x2427go/ast.walkList[...]:=21,+0x205bgo/ast.Walk:+51,+0x2048go/ast.Walk:+102,+0x2427go/ast.walkList[...]:=21,+0x205bgo/ast.Walk:+51,+0x2048go/ast.walkList[...]:=21,+0x1b0bgo/ast.Walk:+161,+0x1abcgo/ast.walkList[...]:=21,+0x1f47go/ast.Walk:+178,+0xc40go/ast.Walk:+299,+0x4cfgo/ast.Inspect:=372,+0x107golang.org/x/tools/internal/refactor/inline.escape:+46,+0xa4golang.org/x/tools/internal/refactor/inline.(*state).inlineCall:+40,+0x2dfgolang.org/x/tools/internal/refactor/inline.(*state).inline:+17,+0x1e7
golang.org/x/tools/gopls@v0.19.1 go1.24.4 darwin/arm64 vscode (2)