/ tests / tests / execution / const_generics.adl
const_generics.adl
 1  /*
 2  seed = 123456789
 3  min_height = 16
 4  
 5  [case]
 6  program = "test.alpha"
 7  function = "main"
 8  input = []
 9  */
10  
11  program test.alpha {
12      const M: u32 = 1u32;
13      const P: u32 = 2u32;
14  
15      transition main() -> u32 {
16          let sum = 0u32;
17          for i in 0u32..5u32 {
18              sum += sum_first_n_ints::[M + i]() + sum_first_n_ints::[P + i]();
19          }
20  
21          return  sum
22                + sum_first_n_ints::[2 * 3]()
23                + other::[5](); // this call to `other` will get resolved in the first pass of monomorphization
24      }
25  
26      inline sum_first_n_ints::[N: u32]() -> u32 {
27          let sum = 0u32;
28          for i in 0u32..N {
29              sum += i + other::[i](); // this call to `other` will be resolved in the second pass of monomorphization
30          }
31          return sum;
32      }
33  
34      inline other::[Q: u32]() -> u32 {
35          return Q;
36      }
37  
38      @noupgrade
39      async constructor() {}
40  }