From ef7212e2cfc786e5b81a0d3ac55371628177e013 Mon Sep 17 00:00:00 2001 From: Yury Smolsky Date: Mon, 28 May 2018 17:15:11 +0300 Subject: [PATCH] cmd/compile: use yyerrorl(n.Pos, ...) in typecheckdef n.Pos.IsKnown() is not needed because it is performed in setlineno. toolstash-check passed. Updates #19683. Change-Id: I34d6a0e6dc9970679d99e8f3424f289ebf1e86ba Reviewed-on: https://go-review.googlesource.com/114915 Run-TryBot: Yury Smolsky TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/gc/typecheck.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index bb78d8bf73..c2b8454185 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -3640,25 +3640,22 @@ func typecheckdeftype(n *Node) { } 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 } @@ -3701,20 +3698,19 @@ func typecheckdef(n *Node) { 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) } @@ -3724,12 +3720,12 @@ func typecheckdef(n *Node) { 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 } -- 2.50.0