/ tests / tests / compiler / const_generics / basic.adl
basic.adl
 1  program test.alpha {
 2      const M: u32 = 1u32;
 3      const P: u32 = 2u32;
 4  
 5      transition main() -> u32 {
 6          let sum = 0u32;
 7          for i in 0u32..5u32 {
 8              sum += sum_first_n_ints::[M + i]() + sum_first_n_ints::[P + i]();
 9          }
10  
11          return  sum
12                + sum_first_n_ints::[2 * 3]()
13                + other::[5](); // this call to `other` will get resolved in the first pass of monomorphization
14      }
15  
16      inline sum_first_n_ints::[N: u32]() -> u32 {
17          let sum = 0u32;
18          for i in 0u32..N {
19              sum += i + other::[i](); // this call to `other` will be resolved in the second pass of monomorphization
20          }
21          return sum;
22      }
23  
24      inline other::[Q: u32]() -> u32 {
25          return Q;
26      }
27  }