/ tests / tests / compiler / const_generics / basic_const_generic_structs.adl
basic_const_generic_structs.adl
 1  program test.alpha {
 2      const M: u32 = 52;
 3  
 4      struct Foo::[N: u32] {
 5          arr: [u32; N],
 6      }
 7  
 8      struct Goo::[P: u32] {
 9          f: Foo::[P],
10      }
11  
12      struct Boo::[P: u32] {
13          g: Goo::[P],
14      }
15  
16      struct Baz {
17          f: Foo::[10u32],
18      }
19  
20      transition main(g: Goo::[7u32], b: Baz, x: u32) -> u32 {
21          let g2 = Goo::[6u32] {
22              f: Foo::[6u32] {
23                  arr: [42u32; 6],
24              }
25          };
26  
27          let s: Foo::[8u32] = Foo::[8u32] {
28              arr: [3; 8]
29          };
30  
31          let boo: Boo::[9u32] = Boo::[9u32] {
32              g: Goo::[9u32] {
33                  f: Foo::[9u32] {
34                      arr: [42u32; 9],
35                  }
36              }
37          };
38  
39          let baz = Baz {
40              f: Foo::[10u32] {
41                  arr: [52; 10]
42              }
43          };
44  
45          return g.f.arr[6] + s.arr[7] + g2.f.arr[5] + boo.g.f.arr[8];
46      }
47  }