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: failure to compile valid switch statement #15895

Closed
josharian opened this issue May 30, 2016 · 3 comments
Closed

cmd/compile: failure to compile valid switch statement #15895

josharian opened this issue May 30, 2016 · 3 comments
Milestone

Comments

@josharian
Copy link
Contributor

package p

type A [1]int

func bad(x A) {
    switch x {
    case A([1]int{1}):
    case A([1]int{1}):
    }
}

func good(x A) {
    y := A([1]int{1})
    z := A([1]int{1})
    switch x {
    case y:
    case z:
    }
}

Compiling this code generates:

x.go:7: cannot use &statictmp_1 (type *[1]int) as type *A in assignment
x.go:8: cannot use &statictmp_4 (type *[1]int) as type *A in assignment

Observe that func good is more or less equivalent to func bad, but it compiles. The reported types in the error message are also wrong: x is an A, not a *A.

Reproduces in 1.4, 1.5, and 1.6, so setting milestone to 1.8.

@martisch
Copy link
Contributor

martisch commented Sep 3, 2016

Cant reproduce the compile error on tip.

@josharian
Copy link
Contributor Author

Probably fixed by my switch rewrites. I'd like to close this by adding this to test/fixedbugs, so leaving open for the moment.

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Sep 4, 2017
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

3 participants