nx_probe_castidx_live.nx source
↩ module page · 16 lines · 930 B
1// nx_probe_castidx_live.nx -- WITNESS for the paren-primary postfix chain (parse_primary TK_LPAREN).
2// TRAP (documented 2026-08-07, fixed 2026-08-13): indexing an INLINE-CAST string literal
3// `("lit" as *u8)[j]` compiled clean and never compared equal -- the pending `[` silently
4// terminated the expression, the pointer landed truncated in the receiver (measured 213 = addr&0xFF),
5// and in an if-condition the leftover `[` desynced the parser (kind=47 at expression start).
6// REPRO (pre-fix): build+run this -> exit 1/2/3 or COMPILE-FAIL; post-fix -> builds AND exits 0.
7// exit 0 = correct; 1 = inline-cast index disagrees with hoisted index; 2 = hoisted form wrong; 3 = if-condition shape wrong.
8func main(argc: i64, argv: *u8) -> i64 {
9 let n: *u8 = "AB" as *u8
10 let a: i64 = n[0]
11 if a != 65 { return 2 }
12 let b: i64 = ("AB" as *u8)[0]
13 if b != a { return 1 }
14 if ("AB" as *u8)[1] != 66 { return 3 }
15 return 0
16}