Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: "invalid variable name x in type switch", where x is a name of a constant #12413

Closed
o948 opened this issue Aug 31, 2015 · 3 comments
Milestone

Comments

@o948
Copy link

o948 commented Aug 31, 2015

The following program fails to build (http://play.golang.org/p/qrVKDN_MDR):

package main

const x = 42

func main() {
    switch x := interface{}(nil).(type) {
    default:
        _ = x
    }
}

with the error message:

prog.go:6: invalid variable name x in type switch
@ianlancetaylor ianlancetaylor changed the title go/gc: "invalid variable name x in type switch", where x is a name of a constant cmd/compile: "invalid variable name x in type switch", where x is a name of a constant Aug 31, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Aug 31, 2015
@ianlancetaylor
Copy link
Contributor

Compiler bug rejecting a valid program. Works with gccgo.

@anthonycanino1
Copy link
Contributor

Have an idea with what is wrong: Looks like x in the type switch grabs the const x symbol during parsing, which gives it the OLITERAL op that then errors in the type switch. Looking into a fix.

@gopherbot
Copy link

CL https://golang.org/cl/15760 mentions this issue.

@minux minux closed this as completed in b60c820 Oct 21, 2015
@golang golang locked and limited conversation to collaborators Oct 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants