aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2017-09-23 23:04:31 +0100
committerDaniel Martí <mvdan@mvdan.cc>2017-09-24 10:15:52 +0000
commit24ca86f3083e8dd4ad5ea61e26acf02440d0ad35 (patch)
treef460f0c05b2c0023ca55e67fa84b9185f790098f /src
parent7739b8a97fb767ceb141af05a1213b538c32e8da (diff)
downloadgo-24ca86f3083e8dd4ad5ea61e26acf02440d0ad35.tar.xz
cmd/compile: fix invalid switch case value panic
This is a regression introduced by myself in golang.org/cl/41852, confirmed by the program that reproduces the crash that can be seen in the added test. Fixes #21988. Change-Id: I18d5b2b3de63ced84db705b18490b00b16b59e02 Reviewed-on: https://go-review.googlesource.com/65655 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/swt.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/swt.go b/src/cmd/compile/internal/gc/swt.go
index 469af86aa6..dc285ae91c 100644
--- a/src/cmd/compile/internal/gc/swt.go
+++ b/src/cmd/compile/internal/gc/swt.go
@@ -610,6 +610,11 @@ func checkDupExprCases(exprname *Node, clauses []*Node) {
if ct := consttype(n); ct < 0 || ct == CTBOOL {
continue
}
+ // If the value has no type, we have
+ // already printed an error about it.
+ if n.Type == nil {
+ continue
+ }
val := n.Val().Interface()
prev, dup := seen[val]