1// +build ignore
2
3package main
4
5// Test of value flow from panic() to recover().
6// We model them as stores/loads of a global location.
7// We ignore concrete panic types originating from the runtime.
8
9var someval int
10
11type myPanic struct{}
12
13func f(int) {}
14
15func g() string { return "" }
16
17func deadcode() {
18	panic(123) // not reached
19}
20
21func main() {
22	switch someval {
23	case 0:
24		panic("oops")
25	case 1:
26		panic(myPanic{})
27	case 2:
28		panic(f)
29	case 3:
30		panic(g)
31	}
32	ex := recover()
33	print(ex)                 // @types myPanic | string | func(int) | func() string
34	print(ex.(func(int)))     // @pointsto main.f
35	print(ex.(func() string)) // @pointsto main.g
36}
37