And use base.Fatalf in code that use n.SetDiag(true) instead.
Updates #51691
Change-Id: Ib3c0b9c89b8d95717391cbe7d424240e288ada1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/394575
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
package ir
import (
- "cmd/compile/internal/base"
"cmd/compile/internal/types"
"cmd/internal/src"
"fmt"
n.bits.set2(miniTypecheckShift, x)
}
-func (n *miniNode) SetDiag(x bool) { base.AssertfAt(!x, n.Pos(), "SetDiag") }
-
func (n *miniNode) Walked() bool { return n.bits&miniWalked != 0 }
func (n *miniNode) SetWalked(x bool) { n.bits.set(miniWalked, x) }
// Storage for analysis passes.
Esc() uint16
SetEsc(x uint16)
- SetDiag(x bool)
// Typecheck values:
// 0 means the node is not typechecked
}
n = ir.Copy(n)
if t == nil {
- base.Errorf("use of untyped nil")
- n.SetDiag(true)
- n.SetType(nil)
- return n
+ base.Fatalf("use of untyped nil")
}
if !t.HasNil() {
}
if explicit {
- base.Errorf("cannot convert %L to type %v", n, t)
+ base.Fatalf("cannot convert %L to type %v", n, t)
} else if context != nil {
- base.Errorf("cannot use %L as type %v in %s", n, t, context())
+ base.Fatalf("cannot use %L as type %v in %s", n, t, context())
} else {
- base.Errorf("cannot use %L as type %v", n, t)
+ base.Fatalf("cannot use %L as type %v", n, t)
}
- n.SetDiag(true)
n.SetType(nil)
return n
}
op, why := Convertop(n.X.Op() == ir.OLITERAL, t, n.Type())
if op == ir.OXXX {
- base.Errorf("cannot convert %L to type %v%s", n.X, n.Type(), why)
- n.SetDiag(true)
- n.SetOp(ir.OCONV)
- n.SetType(nil)
- return n
+ base.Fatalf("cannot convert %L to type %v%s", n.X, n.Type(), why)
}
n.SetOp(op)
l = n.X
if l.Op() == ir.OTYPE {
if n.IsDDD {
- base.Errorf("invalid use of ... in type conversion to %v", l.Type())
- n.SetDiag(true)
+ base.Fatalf("invalid use of ... in type conversion to %v", l.Type())
}
// pick off before type-checking arguments
// The syntax made sure it was a call, so this must be
// a conversion.
- n.SetDiag(true)
- base.ErrorfAt(n.Pos(), "%s requires function call, not conversion", what)
+ base.FatalfAt(n.Pos(), "%s requires function call, not conversion", what)
}
// tcIf typechecks an OIF node.
case ir.ONONAME:
// Note: adderrorname looks for this string and
// adds context about the outer expression
- base.ErrorfAt(n.Pos(), "undefined: %v", n.Sym())
- n.SetDiag(true)
- n.SetType(nil)
- return n
+ base.FatalfAt(n.Pos(), "undefined: %v", n.Sym())
+ panic("unreachable")
case ir.ONAME:
n := n.(*ir.Name)
case ir.OTYPESW:
n := n.(*ir.TypeSwitchGuard)
- base.Errorf("use of .(type) outside type switch")
- n.SetDiag(true)
+ base.Fatalf("use of .(type) outside type switch")
return n
case ir.ODCLFUNC:
base.Errorf("not enough arguments to %v%s", op, details)
}
if n != nil {
- n.SetDiag(true)
+ base.Fatalf("invalid call")
}
}
return
elt.Key = Expr(elt.Key)
key = IndexConst(elt.Key)
if key < 0 {
- if key == -2 {
- base.Errorf("index too large")
- } else {
- base.Errorf("index must be non-negative integer constant")
- }
- elt.Key.SetDiag(true)
- key = -(1 << 30) // stay negative for a while
+ base.Fatalf("invalid index: %v", elt.Key)
}
kv = elt
r = elt.Value