@@ -3640,25 +3640,22 @@ func typecheckdeftype(n *Node) {
3640
3640
}
3641
3641
3642
3642
func typecheckdef (n * Node ) {
3643
- lno := lineno
3644
- setlineno (n )
3643
+ lno := setlineno (n )
3645
3644
3646
3645
if n .Op == ONONAME {
3647
3646
if ! n .Diag () {
3648
3647
n .SetDiag (true )
3649
- if n .Pos .IsKnown () {
3650
- lineno = n .Pos
3651
- }
3652
3648
3653
3649
// Note: adderrorname looks for this string and
3654
3650
// adds context about the outer expression
3655
- yyerror ( "undefined: %v" , n .Sym )
3651
+ yyerrorl ( lineno , "undefined: %v" , n .Sym )
3656
3652
}
3657
-
3653
+ lineno = lno
3658
3654
return
3659
3655
}
3660
3656
3661
3657
if n .Walkdef () == 1 {
3658
+ lineno = lno
3662
3659
return
3663
3660
}
3664
3661
@@ -3701,20 +3698,19 @@ func typecheckdef(n *Node) {
3701
3698
e := n .Name .Defn
3702
3699
n .Name .Defn = nil
3703
3700
if e == nil {
3704
- lineno = n .Pos
3705
3701
Dump ("typecheckdef nil defn" , n )
3706
- yyerror ( "xxx" )
3702
+ yyerrorl ( n . Pos , "xxx" )
3707
3703
}
3708
3704
3709
3705
e = typecheck (e , Erv )
3710
3706
if Isconst (e , CTNIL ) {
3711
- yyerror ( "const initializer cannot be nil" )
3707
+ yyerrorl ( n . Pos , "const initializer cannot be nil" )
3712
3708
goto ret
3713
3709
}
3714
3710
3715
3711
if e .Type != nil && e .Op != OLITERAL || ! e .isGoConst () {
3716
3712
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 )
3718
3714
e .SetDiag (true )
3719
3715
}
3720
3716
@@ -3724,12 +3720,12 @@ func typecheckdef(n *Node) {
3724
3720
t := n .Type
3725
3721
if t != nil {
3726
3722
if ! okforconst [t .Etype ] {
3727
- yyerror ( "invalid constant type %v" , t )
3723
+ yyerrorl ( n . Pos , "invalid constant type %v" , t )
3728
3724
goto ret
3729
3725
}
3730
3726
3731
3727
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 )
3733
3729
goto ret
3734
3730
}
3735
3731
0 commit comments