| // Copyright 2016 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // Verify that switch statements with duplicate cases are detected by the compiler. |
| case 0: // ERROR "duplicate case 0 in switch" |
| case int(0): // ERROR "duplicate case 0 in switch" |
| case 5: // ERROR "duplicate case 5 in switch" |
| case 5.0: // ERROR "duplicate case 5 in switch" |
| case "": // ERROR "duplicate case .. in switch" |
| case "abc": // ERROR "duplicate case .abc. in switch" |
| case 0: // ERROR "duplicate case 0 in switch" |
| case float32(10): // ERROR "duplicate case float32\(10\) in switch" |
| case float64(10): // ERROR "duplicate case float64\(10\) in switch" |
| case int: // ERROR "duplicate case int in type switch" |
| case error: // ERROR "duplicate case error in type switch" |
| case fmt.Stringer: // ERROR "duplicate case fmt.Stringer in type switch" |
| }: // ERROR "duplicate case struct { i int .tag1. } in type switch" |
| case [1]int{0}: // OK -- see issue 15896 |
| // Ensure duplicate const bool clauses are accepted. |
| case 1 == 1: // Intentionally OK, even though a duplicate of the above const true |