-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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/crash
runtime.gopanic:+69,+0x153
runtime.panicmem:=262,+0x2ff
runtime.sigpanic:+19,+0x2cc
golang.org/x/tools/internal/refactor/inline.escape.func1:+27,+0xb4
golang.org/x/tools/internal/refactor/inline.escape.func2:+4,+0xbb
go/ast.inspector.Visit:+1,+0x37
go/ast.Walk:+1,+0x43
go/ast.Walk:+102,+0x2427
go/ast.walkList[...]:=21,+0x205b
go/ast.Walk:+51,+0x2048
go/ast.Walk:+102,+0x2427
go/ast.walkList[...]:=21,+0x205b
go/ast.Walk:+51,+0x2048
go/ast.walkList[...]:=21,+0x1b0b
go/ast.Walk:+161,+0x1abc
go/ast.walkList[...]:=21,+0x1f47
go/ast.Walk:+178,+0xc40
go/ast.Walk:+299,+0x4cf
go/ast.Inspect:=372,+0x107
golang.org/x/tools/internal/refactor/inline.escape:+46,+0xa4
golang.org/x/tools/internal/refactor/inline.(*state).inlineCall:+40,+0x2df
golang.org/x/tools/internal/refactor/inline.(*state).inline:+17,+0x1e7
golang.org/x/tools/[email protected] go1.24.4 darwin/arm64 vscode (2)