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>
diff --git a/test/switch5.go b/test/switch5.go
index 54a11b5..5ca53ba 100644
--- a/test/switch5.go
+++ b/test/switch5.go
@@ -90,3 +90,12 @@
 	}
 	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"
+	}
+}