code wiki / (root) / nx_for_probe.nx

nx_for_probe.nx source

↩ module page · 23 lines · 665 B

1// nx_for_probe.nx -- minimal @for repro. Isolates range expansion from everything else in v5. 2// expect_exit: 0 license_tier: ORIGINAL 3 4import "nx_syscalls.nx" 5 6func fp_w(s: *u8) -> i64 { 7 var n: i64 = 0 8 while s[n] != (0 as u8) { n = n + 1 } 9 sys_write(1, s, n) 10 return 0 11} 12 13@for(i in 0..3) { 14 func fp_val_$i() -> i64 { return $i * 10 } 15} 16 17func main() -> i64 { 18 if fp_val_0() != 0 { fp_w("T0 FAIL\n" as *u8); return 1 } 19 if fp_val_1() != 10 { fp_w("T1 FAIL\n" as *u8); return 2 } 20 if fp_val_2() != 20 { fp_w("T2 FAIL\n" as *u8); return 3 } 21 fp_w("FOR-PROBE OK: 0..3 emitted fp_val_0/1/2 with $i substituted\n" as *u8) 22 return 0 23}