Skip to content

Commit ef7212e

Browse files
Yury Smolskygriesemer
Yury Smolsky
authored andcommitted
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent aa4fc0e commit ef7212e

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/cmd/compile/internal/gc/typecheck.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,25 +3640,22 @@ func typecheckdeftype(n *Node) {
36403640
}
36413641

36423642
func typecheckdef(n *Node) {
3643-
lno := lineno
3644-
setlineno(n)
3643+
lno := setlineno(n)
36453644

36463645
if n.Op == ONONAME {
36473646
if !n.Diag() {
36483647
n.SetDiag(true)
3649-
if n.Pos.IsKnown() {
3650-
lineno = n.Pos
3651-
}
36523648

36533649
// Note: adderrorname looks for this string and
36543650
// adds context about the outer expression
3655-
yyerror("undefined: %v", n.Sym)
3651+
yyerrorl(lineno, "undefined: %v", n.Sym)
36563652
}
3657-
3653+
lineno = lno
36583654
return
36593655
}
36603656

36613657
if n.Walkdef() == 1 {
3658+
lineno = lno
36623659
return
36633660
}
36643661

@@ -3701,20 +3698,19 @@ func typecheckdef(n *Node) {
37013698
e := n.Name.Defn
37023699
n.Name.Defn = nil
37033700
if e == nil {
3704-
lineno = n.Pos
37053701
Dump("typecheckdef nil defn", n)
3706-
yyerror("xxx")
3702+
yyerrorl(n.Pos, "xxx")
37073703
}
37083704

37093705
e = typecheck(e, Erv)
37103706
if Isconst(e, CTNIL) {
3711-
yyerror("const initializer cannot be nil")
3707+
yyerrorl(n.Pos, "const initializer cannot be nil")
37123708
goto ret
37133709
}
37143710

37153711
if e.Type != nil && e.Op != OLITERAL || !e.isGoConst() {
37163712
if !e.Diag() {
3717-
yyerror("const initializer %v is not a constant", e)
3713+
yyerrorl(n.Pos, "const initializer %v is not a constant", e)
37183714
e.SetDiag(true)
37193715
}
37203716

@@ -3724,12 +3720,12 @@ func typecheckdef(n *Node) {
37243720
t := n.Type
37253721
if t != nil {
37263722
if !okforconst[t.Etype] {
3727-
yyerror("invalid constant type %v", t)
3723+
yyerrorl(n.Pos, "invalid constant type %v", t)
37283724
goto ret
37293725
}
37303726

37313727
if !e.Type.IsUntyped() && !eqtype(t, e.Type) {
3732-
yyerror("cannot use %L as type %v in const initializer", e, t)
3728+
yyerrorl(n.Pos, "cannot use %L as type %v in const initializer", e, t)
37333729
goto ret
37343730
}
37353731

0 commit comments

Comments
 (0)