Russ Cox | 57eb06f | 2012-02-16 23:51:04 -0500 | [diff] [blame] | 1 | // run |
Russ Cox | 919cb2e | 2011-09-05 15:31:22 -0400 | [diff] [blame] | 2 | |
| 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. |
| 6 | |
Rob Pike | 80a9783 | 2012-02-24 11:48:19 +1100 | [diff] [blame] | 7 | // Test zero length structs. |
| 8 | // Used to not be evaluated. |
| 9 | // Issue 2232. |
Russ Cox | 919cb2e | 2011-09-05 15:31:22 -0400 | [diff] [blame] | 10 | |
| 11 | package main |
| 12 | |
| 13 | func recv(c chan interface{}) struct{} { |
| 14 | return (<-c).(struct{}) |
| 15 | } |
| 16 | |
| 17 | var m = make(map[interface{}]int) |
| 18 | |
| 19 | func recv1(c chan interface{}) { |
| 20 | defer rec() |
| 21 | m[(<-c).(struct{})] = 0 |
| 22 | } |
| 23 | |
| 24 | func rec() { |
| 25 | recover() |
| 26 | } |
| 27 | |
| 28 | func main() { |
| 29 | c := make(chan interface{}) |
| 30 | go recv(c) |
| 31 | c <- struct{}{} |
| 32 | go recv1(c) |
| 33 | c <- struct{}{} |
| 34 | } |