cmd/compile: confusing compiler error when using if instead of for with range operator inside anonymous function #38624
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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: