blob: 26bdeabb259121e3f5fbe98846bed3f9207905b5 [file] [log] [blame]
Russ Cox20e97672014-08-25 07:05:45 -04001// 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
9package main
10
11type X struct {
12 c chan int
13}
14
15func 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
26func foo() chan int {
27 println("BUG: foo must not be called")
28 return make(chan int)
29}