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: panic on interface switch case with invalid name #22063

mvdan opened this issue Sep 27, 2017 · 1 comment

cmd/compile: panic on interface switch case with invalid name #22063

mvdan opened this issue Sep 27, 2017 · 1 comment


Copy link

@mvdan mvdan commented Sep 27, 2017

Another variation of #21988, this time using an interface type. Found it manually by inspecting the source code as there was a .Val().Interface() use without the appropriate .Type == nil check.


package p

const X = Wrong(0)

func _() {
        switch interface{}(nil) {
        case X:
 $ go build f.go
# command-line-arguments
./f.go:3:11: undefined: Wrong
./f.go:6:9: internal compiler error: unexpected Interface for <nil>

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
        /home/mvdan/tip/src/runtime/debug/stack.go:24 +0xa7
cmd/compile/internal/gc.Fatalf(0xb79d29, 0x1b, 0xc4203320d8, 0x1, 0x1)
        /home/mvdan/tip/src/cmd/compile/internal/gc/subr.go:181 +0x1e2
cmd/compile/internal/gc.Val.Interface(0x0, 0x0, 0x3, 0xc4203322a8)
        /home/mvdan/tip/src/cmd/compile/internal/gc/const.go:99 +0x2c8
cmd/compile/internal/gc.checkDupExprCases(0xc420308d80, 0xc42000c578, 0x1, 0x1)
        /home/mvdan/tip/src/cmd/compile/internal/gc/swt.go:645 +0x1a9
        /home/mvdan/tip/src/cmd/compile/internal/gc/swt.go:210 +0x12cc
cmd/compile/internal/gc.typecheck1(0xc420308c80, 0x1, 0x4b144b)
        /home/mvdan/tip/src/cmd/compile/internal/gc/typecheck.go:2098 +0xc10d
cmd/compile/internal/gc.typecheck(0xc420308c80, 0x1, 0x3)
        /home/mvdan/tip/src/cmd/compile/internal/gc/typecheck.go:201 +0x694
cmd/compile/internal/gc.typecheckslice(0xc42000c580, 0x1, 0x1, 0x1)
        /home/mvdan/tip/src/cmd/compile/internal/gc/typecheck.go:55 +0x54
        /home/mvdan/tip/src/cmd/compile/internal/gc/main.go:486 +0x1f3c
        /home/mvdan/tip/src/cmd/compile/main.go:49 +0x89

Reproduces on both go version devel +0d0c1132f6 Wed Sep 27 04:01:40 2017 +0000 linux/amd64 and 1.9.

@mvdan mvdan added this to the Go1.10 milestone Sep 27, 2017
@mvdan mvdan self-assigned this Sep 27, 2017

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Sep 27, 2017

Change mentions this issue: cmd/compile: fix another invalid switch case panic

@gopherbot gopherbot closed this in 39e5237 Sep 27, 2017
@golang golang locked and limited conversation to collaborators Sep 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.