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: wrong error "use of .(type) outside of type switch" if using undefined type #19977

Closed
mvdan opened this issue Apr 14, 2017 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Apr 14, 2017

What version of Go are you using (go version)?

Present in both tip and 1.8:

go version devel +7337181daf Fri Apr 14 08:44:45 2017 +0000 linux/amd64
go version go1.8.1 linux/amd64

What did you do?

Compile f.go:

package foo

func Foo(a bar) {
        switch x := a.(type) {
        default:
                _ = x
        }
}

What did you expect to see?

./f.go:3: undefined: bar

What did you see instead?

./f.go:3:12: undefined: bar
./f.go:4:15: use of .(type) outside type switch

Not urgent because the correct error is right above it, but this error is still wrong and unnecessary.

@mvdan
Copy link
Member Author

mvdan commented Apr 14, 2017

Slightly smaller repro:

package foo

func Foo() {
        switch x := a.(type) {
        default:
                _ = x
        }
}
./f.go:4: undefined: a
./f.go:4: use of .(type) outside type switch

@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 30, 2017
@bradfitz bradfitz added this to the Go1.9 milestone Apr 30, 2017
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Apr 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants