]> Cypherpunks.ru repositories - gostls13.git/blob - test/switch7.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / switch7.go
1 // errorcheck
2
3 // Copyright 2016 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // Verify that type switch statements with duplicate cases are detected
8 // by the compiler.
9 // Does not compile.
10
11 package main
12
13 import "fmt"
14
15 func f4(e interface{}) {
16         switch e.(type) {
17         case int:
18         case int: // ERROR "duplicate case int in type switch"
19         case int64:
20         case error:
21         case error: // ERROR "duplicate case error in type switch"
22         case fmt.Stringer:
23         case fmt.Stringer: // ERROR "duplicate case fmt.Stringer in type switch"
24         case struct {
25                 i int "tag1"
26         }:
27         case struct {
28                 i int "tag2"
29         }:
30         case struct { // ERROR "duplicate case struct { i int .tag1. } in type switch|duplicate case"
31                 i int "tag1"
32         }:
33         }
34 }
35