mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00
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>
This commit is contained in:
parent
2827923800
commit
6eede325ab
2 changed files with 30 additions and 18 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue