]> Cypherpunks.ru repositories - gostls13.git/blob - test/typeswitch2.go
test: match gccgo error messages
[gostls13.git] / test / typeswitch2.go
1 // errchk $G -e $D/$F.go
2
3 // Copyright 2009 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 package main
8
9 import "io"
10
11 func whatis(x interface{}) string {
12         switch x.(type) {
13         case int:
14                 return "int"
15         case int: // ERROR "duplicate"
16                 return "int8"
17         case io.Reader:
18                 return "Reader1"
19         case io.Reader: // ERROR "duplicate"
20                 return "Reader2"
21         case interface {
22                 r()
23                 w()
24         }:
25                 return "rw"
26         case interface {        // GCCGO_ERROR "duplicate"
27                 w()
28                 r()
29         }: // GC_ERROR "duplicate"
30                 return "wr"
31
32         }
33         return ""
34 }
35
36 func notused(x interface{}) {
37         // The first t is in a different scope than the 2nd t; it cannot
38         // be accessed (=> declared and not used error); but it is legal
39         // to declare it.
40         switch t := 0; t := x.(type) { // ERROR "declared and not used"
41         case int:
42                 _ = t // this is using the t of "t := x.(type)"
43         }
44 }