| 1 |
// run |
| 2 |
|
| 3 |
// Copyright 2014 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 |
// Issue 8336. Order of evaluation of receive channels in select. |
| 8 |
|
| 9 |
package main |
| 10 |
|
| 11 |
type X struct { |
| 12 |
c chan int |
| 13 |
} |
| 14 |
|
| 15 |
func main() { |
| 16 |
defer func() { |
| 17 |
recover() |
| 18 |
}() |
| 19 |
var x *X |
| 20 |
select { |
| 21 |
case <-x.c: // should fault and panic before foo is called |
| 22 |
case <-foo(): |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
func foo() chan int { |
| 27 |
println("BUG: foo must not be called") |
| 28 |
return make(chan int) |
| 29 |
} |