code wiki / (root) / nx_probe_match.nx

nx_probe_match.nx source

↩ module page · 34 lines · 927 B

1// nx_probe_match.nx -- EVIDENCE GATE for the disputed "exhaustive match 2// is dead code" claim. Compiles a real `match` (plain enum + tagged enum 3// with payload binding) through the SOVEREIGN chain (nx_cc_sovereign -> 4// nxasm_x86_main). If run-exit=0, match WORKS sovereignly. Syntax mirrors 5// end2end_test.nx Cases 10 + 12. 6// expect_exit: 0 7 8enum Color { Red, Green, Blue } 9enum Opt { None, Some(i64) } 10 11func classify(c: i64) -> i64 { 12 match c { 13 Color::Red => { return 10 }, 14 Color::Green => { return 20 }, 15 Color::Blue => { return 30 } 16 } 17 return 0 18} 19 20func main() -> i64 { 21 if classify(Color::Green) != 20 { return 1 } 22 if classify(Color::Blue) != 30 { return 2 } 23 24 // tagged enum + payload binding 25 let o: *Opt = Opt::Some(42) 26 var r: i64 = 0 27 match o { 28 Opt::None => { r = 0 }, 29 Opt::Some(v) => { r = v } 30 } 31 if r != 42 { return 3 } 32 33 return 0 34}