1
2
3
4
5
6
7 package main
8
9 import (
10 "runtime"
11 "strings"
12 )
13
14 var t *struct {
15 c chan int
16 }
17
18 var c chan int
19
20 func f() {
21 select {
22 case <-t.c:
23 break
24 case <-c:
25 break
26 }
27 }
28
29 func main() {
30 defer func() {
31 recover()
32 for i := 0;; i++ {
33 pc, file, line, ok := runtime.Caller(i)
34 if !ok {
35 print("BUG: bug347: cannot find caller\n")
36 return
37 }
38 if !strings.Contains(file, "bug347.go") || runtime.FuncForPC(pc).Name() != "main.f" {
39
40 continue
41 }
42 if line != 22 {
43 print("BUG: bug347: panic at ", file, ":", line, " in ", runtime.FuncForPC(pc).Name(), "\n")
44 }
45 return
46 }
47 }()
48 f()
49 }
50
View as plain text