}
func typecheckdef(n *Node) {
- lno := lineno
- setlineno(n)
+ lno := setlineno(n)
if n.Op == ONONAME {
if !n.Diag() {
n.SetDiag(true)
- if n.Pos.IsKnown() {
- lineno = n.Pos
- }
// Note: adderrorname looks for this string and
// adds context about the outer expression
- yyerror("undefined: %v", n.Sym)
+ yyerrorl(lineno, "undefined: %v", n.Sym)
}
-
+ lineno = lno
return
}
if n.Walkdef() == 1 {
+ lineno = lno
return
}
e := n.Name.Defn
n.Name.Defn = nil
if e == nil {
- lineno = n.Pos
Dump("typecheckdef nil defn", n)
- yyerror("xxx")
+ yyerrorl(n.Pos, "xxx")
}
e = typecheck(e, Erv)
if Isconst(e, CTNIL) {
- yyerror("const initializer cannot be nil")
+ yyerrorl(n.Pos, "const initializer cannot be nil")
goto ret
}
if e.Type != nil && e.Op != OLITERAL || !e.isGoConst() {
if !e.Diag() {
- yyerror("const initializer %v is not a constant", e)
+ yyerrorl(n.Pos, "const initializer %v is not a constant", e)
e.SetDiag(true)
}
t := n.Type
if t != nil {
if !okforconst[t.Etype] {
- yyerror("invalid constant type %v", t)
+ yyerrorl(n.Pos, "invalid constant type %v", t)
goto ret
}
if !e.Type.IsUntyped() && !eqtype(t, e.Type) {
- yyerror("cannot use %L as type %v in const initializer", e, t)
+ yyerrorl(n.Pos, "cannot use %L as type %v in const initializer", e, t)
goto ret
}