Source file
test/ken/ptrvar.go
1
2
3
4
5
6
7
8
9 package main
10
11 type x2 struct { a,b,c int; d int; };
12 var g1 x2;
13 var g2 struct { a,b,c int; d x2; };
14
15 func
16 main() {
17 var x int;
18 var s1 *x2;
19 var s2 *struct { a,b,c int; d x2; };
20
21 s1 = &g1;
22 s2 = &g2;
23
24 s1.a = 1;
25 s1.b = 2;
26 s1.c = 3;
27 s1.d = 5;
28
29 s2.a = 7;
30 s2.b = 11;
31 s2.c = 13;
32 s2.d.a = 17;
33 s2.d.b = 19;
34 s2.d.c = 23;
35 s2.d.d = 20;
36
37 if(s2.d.c != 23) { panic(1); }
38 if(g2.d.c != 23) { panic(2); }
39
40 x = s1.a +
41 s1.b +
42 s1.c +
43 s1.d +
44
45 s2.a +
46 s2.b +
47 s2.c +
48 s2.d.a +
49 s2.d.b +
50 s2.d.c +
51 s2.d.d;
52
53 if(x != 121) { panic(x); }
54 }
55
View as plain text