return n
}
- if !n.Diag() {
- if explicit {
- base.Errorf("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())
- } else {
- base.Errorf("cannot use %L as type %v", n, t)
- }
- n.SetDiag(true)
+ if explicit {
+ base.Errorf("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())
+ } else {
+ base.Errorf("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 {
- if !n.Diag() && !n.X.Diag() {
- base.Errorf("cannot convert %L to type %v%s", n.X, n.Type(), why)
- n.SetDiag(true)
- }
+ 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
return
}
- if !n.Diag() {
- // 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)
- }
+ // 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)
}
// tcIf typechecks an OIF node.
// this code a bit, especially the final case.
switch {
case top&(ctxStmt|ctxExpr) == ctxExpr && !isExpr && n.Op() != ir.OTYPE && !isMulti:
- if !n.Diag() {
- base.Errorf("%v used as value", n)
- n.SetDiag(true)
- }
+ base.Errorf("%v used as value", n)
+ n.SetDiag(true)
if t != nil {
n.SetType(nil)
}
n.SetDiag(true)
case top&(ctxStmt|ctxExpr) == ctxStmt && !isStmt && t != nil:
- if !n.Diag() {
- base.Errorf("%v evaluated but not used", n)
- n.SetDiag(true)
- }
+ base.Errorf("%v evaluated but not used", n)
+ n.SetDiag(true)
n.SetType(nil)
case top&(ctxType|ctxExpr) == ctxType && n.Op() != ir.OTYPE && n.Op() != ir.ONONAME && (t != nil || n.Op() == ir.ONAME):
case ir.OLITERAL:
if n.Sym() == nil && n.Type() == nil {
- if !n.Diag() {
- base.Fatalf("literal missing type: %v", n)
- }
+ base.Fatalf("literal missing type: %v", n)
}
return n
// names
case ir.ONONAME:
- if !n.Diag() {
- // Note: adderrorname looks for this string and
- // adds context about the outer expression
- base.ErrorfAt(n.Pos(), "undefined: %v", n.Sym())
- n.SetDiag(true)
- }
+ // 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
case ir.ODEFER, ir.OGO:
n := n.(*ir.GoDeferStmt)
n.Call = typecheck(n.Call, ctxStmt|ctxExpr)
- if !n.Call.Diag() {
- tcGoDefer(n)
- }
+ tcGoDefer(n)
return n
case ir.OFOR, ir.OFORUNTIL:
return
notenough:
- if n == nil || (!n.Diag() && n.Type() != nil) {
+ if n == nil || n.Type() != nil {
details := errorDetails(nl, tstruct, isddd)
if call != nil {
// call is the expression being called, not the overall call.
elt.Key = Expr(elt.Key)
key = IndexConst(elt.Key)
if key < 0 {
- if !elt.Key.Diag() {
- if key == -2 {
- base.Errorf("index too large")
- } else {
- base.Errorf("index must be non-negative integer constant")
- }
- elt.Key.SetDiag(true)
+ 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
}
kv = elt
}
defer n.SetType(nil)
- if n.Diag() {
- return
- }
+
switch {
case n.Op() == ir.ODOT && n.(*ir.SelectorExpr).X.Op() == ir.OINDEXMAP:
base.Errorf("cannot assign to struct field %v in map", n)