cmd/compile: confusing compiler error when using if instead of for with range operator inside anonymous function #38624
Comments
Thanks for the report. This looks like a problem with the parser recovering gracefully in the presence of the syntax error (use of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/DJKZqMtng4S
What did you expect to see?
syntax error: unexpected range, expecting expression
What did you see instead?
expression in go must be function call
When I typically see this error it's because I forgot the () on an anonymous function. In this case I didn't though. Instead, this error is reported when there was an error inside the anonymous function; that being using an if instead of the intended for with the range operator.
The text was updated successfully, but these errors were encountered: