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
cmd/compile/internal/gc.typecheckswitch(0xc420308c80)
/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
cmd/compile/internal/gc.Main(0xb88e40)
/home/mvdan/tip/src/cmd/compile/internal/gc/main.go:486 +0x1f3c
main.main()
/home/mvdan/tip/src/cmd/compile/main.go:49 +0x89
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 == nilcheck.Reproducer:
Reproduces on both
go version devel +0d0c1132f6 Wed Sep 27 04:01:40 2017 +0000 linux/amd64and 1.9.