You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At master, the Go source below produces an error message about line 6:
/tmp/x.go:6: x repeated on left side of :=
However, the error actually originates on line 5, and this was correctly reported at least in Go 1.4.2.
package foo
func f() {
select {
case x, x := <-func() chan int {
c := make(chan int)
return c
}():
}
}
The problem is (*parser).case_ doesn't access p.op (which is storing the LCOLAS token's line number) until after the p.expr() call, which might invalidate p.op if it contains another LCOLAS or LASOP token.
Best fix seems to be to just save lineno before calling p.next() like case LCOLAS in (*parser).simple_stmt. Then _yylex doesn't need to save lexlineno in yylval.i either.
At master, the Go source below produces an error message about line 6:
However, the error actually originates on line 5, and this was correctly reported at least in Go 1.4.2.
The problem is (*parser).case_ doesn't access p.op (which is storing the LCOLAS token's line number) until after the p.expr() call, which might invalidate p.op if it contains another LCOLAS or LASOP token.
Best fix seems to be to just save lineno before calling p.next() like case LCOLAS in (*parser).simple_stmt. Then _yylex doesn't need to save lexlineno in yylval.i either.
CC @griesemer
The text was updated successfully, but these errors were encountered: