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

Comments

Projects
None yet
3 participants
@mvdan
Copy link
Member

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

This comment has been minimized.

Copy link
Member Author

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
@gopherbot

This comment has been minimized.

Copy link

commented Apr 30, 2017

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

@gopherbot gopherbot closed this in cee5cd5 Apr 30, 2017

@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.
You can’t perform that action at this time.