Source file
test/fixedbugs/issue38690.go
1
2
3
4
5
6
7
8
9
10 package main
11
12 type A1 = [0]int
13 type A2 = [1]int
14
15 type S1 struct{}
16
17 type S2 struct {
18 x int
19 }
20
21 type S3 = struct{}
22
23 type S4 = struct{ x int }
24
25 type S struct {
26 x int
27 _ [0]int
28 _ [1]int
29 _ A1
30 _ A2
31 _ S1
32 _ S2
33 _ S3
34 _ S4
35 _ [1]S4
36 }
37
38 var s = S{1, [0]int{}, [1]int{1}, A1{}, A2{1}, S1{}, S2{1}, S3{}, S4{1}, [1]S4{}}
39
40 func main() {
41 f1()
42 mustPanic(f2)
43 mustPanic(f3)
44 }
45
46 func f1() {
47 _ = S{1, [0]int{}, [1]int{1}, A1{}, A2{1}, S1{}, S2{1}, S3{}, S4{1}, [1]S4{}}
48 }
49
50 func f2() {
51 _ = S{1, [0]int{}, [1]int{1}, A1{}, A2{1}, S1{}, S2{1}, S3{}, func() S4 { panic("") }(), [1]S4{}}
52 }
53
54 func f3() {
55 _ = S{1, [0]int{}, [1]int{1}, A1{}, A2{1}, S1{}, S2{1}, S3{}, S4{1}, func() [1]S4 { panic("") }()}
56 }
57
58 func mustPanic(f func()) {
59 defer func() {
60 if recover() == nil {
61 panic("expected panic, got nil")
62 }
63 }()
64 f()
65 }
66
View as plain text