nx_bracedparam_probe.nx source
↩ module page · 27 lines · 828 B
1// nx_bracedparam_probe.nx -- minimal repro for ${param} inside a @macro body (v8 T5 shape).
2// Bare $name cannot express this: `nx_name_apply` reads as ONE identifier run, so the parameter
3// boundary is invisible. Braces make it explicit.
4// expect_exit: 0 license_tier: ORIGINAL
5
6import "nx_syscalls.nx"
7
8func bp_w(s: *u8) -> i64 {
9 var n: i64 = 0
10 while s[n] != (0 as u8) { n = n + 1 }
11 sys_write(1, s, n)
12 return 0
13}
14
15@macro DEFINE_NULL_OP(name) {
16 func nx_${name}_apply(x: i64) -> i64 { return x }
17}
18
19DEFINE_NULL_OP(foo)
20DEFINE_NULL_OP(bar)
21
22func main() -> i64 {
23 if nx_foo_apply(5) != 5 { bp_w("FOO FAIL\n" as *u8); return 1 }
24 if nx_bar_apply(9) != 9 { bp_w("BAR FAIL\n" as *u8); return 2 }
25 bp_w("BRACEDPARAM-PROBE OK: ${name} pasted into nx_foo_apply / nx_bar_apply\n" as *u8)
26 return 0
27}