1
2
3
4
5
6
7 package main
8
9 type T struct {a, b int};
10
11 func println(x, y int) { }
12
13 func f(x interface{}) interface{} {
14 type T struct {a, b int};
15
16 if x == nil {
17 return T{2, 3};
18 }
19
20 t := x.(T);
21 println(t.a, t.b);
22 return x;
23 }
24
25 func main() {
26 inner_T := f(nil);
27 f(inner_T);
28
29 shouldPanic(p1)
30 }
31
32 func p1() {
33 outer_T := T{5, 7};
34 f(outer_T);
35 }
36
37 func shouldPanic(f func()) {
38 defer func() {
39 if recover() == nil {
40 panic("function should panic")
41 }
42 }()
43 f()
44 }
45
46
55
View as plain text