aboutsummaryrefslogtreecommitdiff
path: root/test/switch5.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2016-10-21 14:43:59 -0700
committerMatthew Dempsky <mdempsky@google.com>2016-10-21 22:55:28 +0000
commit6eede325ab9e444c19c8dc4fd5cc6c3603abb93c (patch)
tree8339f516df59bb16c985548630ad73ea70e2f041 /test/switch5.go
parent28279238004da8e83e3d652b4bcd14d6795c6148 (diff)
downloadgo-6eede325ab9e444c19c8dc4fd5cc6c3603abb93c.tar.gz
go-6eede325ab9e444c19c8dc4fd5cc6c3603abb93c.zip
cmd/compile: fix detection of duplicate cases for integer ranges
Previously, the check to make sure we only considered constant cases for duplicates was skipping past integer ranges, because those use n.List instead of n.Left. Thanks to Emmanuel Odeke for investigating and helping to identify the root cause. Fixes #17517. Change-Id: I46fcda8ed9c346ff3a9647d50b83f1555587b740 Reviewed-on: https://go-review.googlesource.com/31716 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'test/switch5.go')
-rw-r--r--test/switch5.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/switch5.go b/test/switch5.go
index 54a11b5c9a..5ca53ba724 100644
--- a/test/switch5.go
+++ b/test/switch5.go
@@ -90,3 +90,12 @@ func f6() int {
}
return 2
}
+
+// Ensure duplicates in ranges are detected (issue #17517).
+func f7(a int) {
+ switch a {
+ case 0:
+ case 0, 1: // ERROR "duplicate case 0"
+ case 1, 2, 3, 4: // ERROR "duplicate case 1"
+ }
+}