nx_probe_closure_capture.nx source
↩ module page · 15 lines · 852 B
1// nx_probe_closure_capture.nx -- LN13b NEGATIVE CONTROL: a function literal that READS a local of
2// the function around it must be REFUSED BY NAME, never compiled.
3//
4// This file is expected NOT to compile. That is its entire purpose: rung 1 admits the
5// non-capturing literal and defers capture-by-value to LN13c, and a rung that merely admitted the
6// easy case while silently miscompiling the hard one would be worse than not shipping. The parser
7// answers an unresolved name with the CONSTANT ZERO, so a capture that slipped through would
8// produce a program that runs, returns a wrong number, and says nothing.
9// license_tier: ORIGINAL. Never built into an artifact. No hw writes (Rule 26).
10
11func main(argc: i64, argv: **u8) -> i64 {
12 let n: i64 = 21
13 let f: func(i64) -> i64 = func(x: i64) -> i64 { return x + n }
14 return f(21)
15}