Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: spurious "goto label jumps over declaration" - 2 #22101
Please answer these questions before submitting your issue. Thanks!
related to #8042 , this program does not compile:
What did you do?
try to compile above
What did you expect to see?
to compile OK
What did you see instead?
referenced this issue
Oct 2, 2017
This isn't a bug, unless am mistaken but the deal is that jumping to a label shouldn't cause new variables to come into scope if it wasn't already in scope i.e
goto L X := 0 L:
introduces a new variable X to go into scope. The original bug declared a type not a variable
X := 0 goto L L:
goto L L: X := 0
are correct but not the code reported.
For extra reference, we can take a look at the spec as well https://golang.org/ref/spec#GotoStmt with the same example coincidentally quoted there.