Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 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 | var ( |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 10 | cr <-chan int |
| 11 | cs chan<- int |
Russ Cox | f4e76d8 | 2011-01-31 18:36:28 -0500 | [diff] [blame] | 12 | c chan int |
Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 13 | ) |
| 14 | |
| 15 | func main() { |
Russ Cox | f4e76d8 | 2011-01-31 18:36:28 -0500 | [diff] [blame] | 16 | cr = c // ok |
| 17 | cs = c // ok |
| 18 | c = cr // ERROR "illegal types|incompatible|cannot" |
| 19 | c = cs // ERROR "illegal types|incompatible|cannot" |
| 20 | cr = cs // ERROR "illegal types|incompatible|cannot" |
| 21 | cs = cr // ERROR "illegal types|incompatible|cannot" |
Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 22 | |
Russ Cox | f4e76d8 | 2011-01-31 18:36:28 -0500 | [diff] [blame] | 23 | c <- 0 // ok |
| 24 | <-c // ok |
| 25 | //TODO(rsc): uncomment when this syntax is valid for receive+check closed |
| 26 | // x, ok := <-c // ok |
| 27 | // _, _ = x, ok |
Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 28 | |
Russ Cox | f4e76d8 | 2011-01-31 18:36:28 -0500 | [diff] [blame] | 29 | cr <- 0 // ERROR "send" |
| 30 | <-cr // ok |
| 31 | //TODO(rsc): uncomment when this syntax is valid for receive+check closed |
| 32 | // x, ok = <-cr // ok |
| 33 | // _, _ = x, ok |
Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 34 | |
Russ Cox | f4e76d8 | 2011-01-31 18:36:28 -0500 | [diff] [blame] | 35 | cs <- 0 // ok |
| 36 | <-cs // ERROR "receive" |
| 37 | ////TODO(rsc): uncomment when this syntax is valid for receive+check closed |
| 38 | //// x, ok = <-cs // ERROR "receive" |
| 39 | //// _, _ = x, ok |
Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 40 | |
| 41 | select { |
Russ Cox | f4e76d8 | 2011-01-31 18:36:28 -0500 | [diff] [blame] | 42 | case c <- 0: // ok |
| 43 | case x := <-c: // ok |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 44 | _ = x |
Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 45 | |
Russ Cox | f4e76d8 | 2011-01-31 18:36:28 -0500 | [diff] [blame] | 46 | case cr <- 0: // ERROR "send" |
| 47 | case x := <-cr: // ok |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 48 | _ = x |
Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 49 | |
Russ Cox | f4e76d8 | 2011-01-31 18:36:28 -0500 | [diff] [blame] | 50 | case cs <- 0: // ok |
| 51 | case x := <-cs: // ERROR "receive" |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 52 | _ = x |
Russ Cox | d33d763 | 2009-05-22 09:53:25 -0700 | [diff] [blame] | 53 | } |
| 54 | } |