PR testsuite/86649
[official-gcc.git] / gcc / testsuite / go.test / test / typeswitch3.go
blob287e32e71e1786caebf57b120df9c35eff4056eb
1 // errorcheck
3 // Copyright 2011 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.
7 // Verify that erroneous type switches are caught be the compiler.
8 // Issue 2700, among other things.
9 // Does not compile.
11 package main
13 import (
14 "io"
17 type I interface {
18 M()
21 func main(){
22 var x I
23 switch x.(type) {
24 case string: // ERROR "impossible"
25 println("FAIL")
28 // Issue 2700: if the case type is an interface, nothing is impossible
30 var r io.Reader
32 _, _ = r.(io.Writer)
34 switch r.(type) {
35 case io.Writer:
38 // Issue 2827.
39 switch _ := r.(type) { // ERROR "invalid variable name _|no new variables"