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
Something like 6:15: syntax error: unexpected ), expecting }
What did you see instead?
6:15: syntax error: i := foo() used as value
I found this in real code (one too many closing parentheses), and it took me five minutes of trying to figure out what was wrong before I spotted the cause. The error didn't point me at the cause well at all.
I realise that the error is technically correct, but in practice I think it could be improved. For example, if you format the original play link, go/parser gives a better message:
6:5: expected boolean expression, found simple statement (missing parentheses around composite literal?) (and 1 more errors)
Happy to try to work on this if it sounds like a good idea. /cc @mdempsky@griesemer
The text was updated successfully, but these errors were encountered:
mvdan
changed the title
cmd/compile: confusing error
cmd/compile: confusing error on if stmt); expr {...}
Nov 5, 2017
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
https://play.golang.org/p/XHC8kt5fa2
What did you expect to see?
Something like
6:15: syntax error: unexpected ), expecting }
What did you see instead?
I found this in real code (one too many closing parentheses), and it took me five minutes of trying to figure out what was wrong before I spotted the cause. The error didn't point me at the cause well at all.
Note that if you use the statement directly, the error is better: https://play.golang.org/p/zcnFf5-Te0
Happens with
switch stmt); expr
too.I realise that the error is technically correct, but in practice I think it could be improved. For example, if you format the original play link,
go/parser
gives a better message:Happy to try to work on this if it sounds like a good idea. /cc @mdempsky @griesemer
The text was updated successfully, but these errors were encountered: