]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: "invalid variable name x in type switch", where x is a name of a constant
authoracanino <anthony.canino1@gmail.com>
Sun, 11 Oct 2015 01:35:22 +0000 (21:35 -0400)
committerMinux Ma <minux@golang.org>
Wed, 21 Oct 2015 04:21:16 +0000 (04:21 +0000)
commitb60c8203eac32eb0d0b11751ba8f85b2f5eada81
tree936e041f2b903fbe49ea6bafba29d227f399ed94
parent3b000b3eaebced151dd80d6c5d37263606368390
cmd/compile: "invalid variable name x in type switch", where x is a name of a constant

Small fix: looks like a short variable declaration with a type switch
checks to make sure the variable used had valid shape (ONAME, OTYPE, or
ONONAME) and rejects everything else. Then a new variable is declared.
If the symbol contained in the declaration was a named OLITERAL (still a
valid identifier obviously) it would be rejected, even though a new
variable would have been declared.

Fix adds this case to the check.

Added a test case from issue12413.

Fixes #12413

Change-Id: I150dadafa8ee5612c867d58031027f2dca8c6ebc
Reviewed-on: https://go-review.googlesource.com/15760
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/go.y
src/cmd/compile/internal/gc/y.go
test/fixedbugs/issue12413.go [new file with mode: 0644]