From: Mateusz Poliwczak Date: Sun, 12 Oct 2025 08:56:13 +0000 (+0200) Subject: cmd/compile/internal/devirtualize: use FatalfAt instead of Fatalf where possible X-Git-Tag: go1.26rc1~624 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0ddb5ed465;p=gostls13.git cmd/compile/internal/devirtualize: use FatalfAt instead of Fatalf where possible Change-Id: I5e9e9c89336446720c3c21347969e4126a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/711140 Reviewed-by: Keith Randall Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov Auto-Submit: Keith Randall --- diff --git a/src/cmd/compile/internal/devirtualize/devirtualize.go b/src/cmd/compile/internal/devirtualize/devirtualize.go index 363cd6f2e5..dfcdd42236 100644 --- a/src/cmd/compile/internal/devirtualize/devirtualize.go +++ b/src/cmd/compile/internal/devirtualize/devirtualize.go @@ -187,7 +187,7 @@ func concreteType(s *State, n ir.Node) (typ *types.Type) { return nil } if typ != nil && typ.IsInterface() { - base.Fatalf("typ.IsInterface() = true; want = false; typ = %v", typ) + base.FatalfAt(n.Pos(), "typ.IsInterface() = true; want = false; typ = %v", typ) } return typ } @@ -226,7 +226,7 @@ func concreteType1(s *State, n ir.Node, seen map[*ir.Name]struct{}) (outT *types if !n1.Type().IsInterface() || !types.Identical(n1.Type().Underlying(), n1.X.Type().Underlying()) { // As we check (directly before this switch) whether n is an interface, thus we should only reach // here for iface conversions where both operands are the same. - base.Fatalf("not identical/interface types found n1.Type = %v; n1.X.Type = %v", n1.Type(), n1.X.Type()) + base.FatalfAt(n1.Pos(), "not identical/interface types found n1.Type = %v; n1.X.Type = %v", n1.Type(), n1.X.Type()) } n = n1.X continue @@ -260,12 +260,12 @@ func concreteType1(s *State, n ir.Node, seen map[*ir.Name]struct{}) (outT *types } if name.Op() != ir.ONAME { - base.Fatalf("name.Op = %v; want = ONAME", n.Op()) + base.FatalfAt(name.Pos(), "name.Op = %v; want = ONAME", n.Op()) } // name.Curfn must be set, as we checked name.Class != ir.PAUTO before. if name.Curfn == nil { - base.Fatalf("name.Curfn = nil; want not nil") + base.FatalfAt(name.Pos(), "name.Curfn = nil; want not nil") } if name.Addrtaken() { @@ -385,11 +385,11 @@ func (s *State) InlinedCall(fun *ir.Func, origCall *ir.CallExpr, inlinedCall *ir func (s *State) assignments(n *ir.Name) []assignment { fun := n.Curfn if fun == nil { - base.Fatalf("n.Curfn = ") + base.FatalfAt(n.Pos(), "n.Curfn = ") } if !n.Type().IsInterface() { - base.Fatalf("name passed to assignments is not of an interface type: %v", n.Type()) + base.FatalfAt(n.Pos(), "name passed to assignments is not of an interface type: %v", n.Type()) } // Analyze assignments in func, if not analyzed before. @@ -430,7 +430,7 @@ func (s *State) analyze(nodes ir.Nodes) { n = n.Canonical() if n.Op() != ir.ONAME { - base.Fatalf("n.Op = %v; want = ONAME", n.Op()) + base.FatalfAt(n.Pos(), "n.Op = %v; want = ONAME", n.Op()) } switch a := assignment.(type) { @@ -492,14 +492,14 @@ func (s *State) analyze(nodes ir.Nodes) { case ir.OAS2DOTTYPE: n := n.(*ir.AssignListStmt) if n.Rhs[0] == nil { - base.Fatalf("n.Rhs[0] == nil; n = %v", n) + base.FatalfAt(n.Pos(), "n.Rhs[0] == nil; n = %v", n) } assign(n.Lhs[0], n.Rhs[0]) assign(n.Lhs[1], nil) // boolean does not have methods to devirtualize case ir.OAS2MAPR, ir.OAS2RECV, ir.OSELRECV2: n := n.(*ir.AssignListStmt) if n.Rhs[0] == nil { - base.Fatalf("n.Rhs[0] == nil; n = %v", n) + base.FatalfAt(n.Pos(), "n.Rhs[0] == nil; n = %v", n) } assign(n.Lhs[0], n.Rhs[0].Type()) assign(n.Lhs[1], nil) // boolean does not have methods to devirtualize @@ -529,7 +529,7 @@ func (s *State) analyze(nodes ir.Nodes) { assign(p, call.ReturnVars[i]) } } else { - base.Fatalf("unexpected type %T in OAS2FUNC Rhs[0]", call) + base.FatalfAt(n.Pos(), "unexpected type %T in OAS2FUNC Rhs[0]", call) } case ir.ORANGE: n := n.(*ir.RangeStmt) @@ -545,7 +545,7 @@ func (s *State) analyze(nodes ir.Nodes) { assign(n.Value, xTyp.Elem()) } else if xTyp.IsChan() { assign(n.Key, xTyp.Elem()) - base.Assertf(n.Value == nil, "n.Value != nil in range over chan") + base.AssertfAt(n.Value == nil, n.Pos(), "n.Value != nil in range over chan") } else if xTyp.IsMap() { assign(n.Key, xTyp.Key()) assign(n.Value, xTyp.Elem()) @@ -556,7 +556,7 @@ func (s *State) analyze(nodes ir.Nodes) { } else { // We will not reach here in case of an range-over-func, as it is // rewrtten to function calls in the noder package. - base.Fatalf("range over unexpected type %v", n.X.Type()) + base.FatalfAt(n.Pos(), "range over unexpected type %v", n.X.Type()) } case ir.OSWITCH: n := n.(*ir.SwitchStmt)