nx_parse_static_gate.nx
buildroot/runtime/nx_parse_static_gate.nx
about
nx_parse_static_gate.nx -- THE MISSING PARSER GATE for the static-as-argument defect.
WHY THIS EXISTS: nx_cc rejects a STATIC passed directly as a function argument with
"nx_parse: argument type mismatch in call to 'F': arg N is a POINTER but the parameter
is an INTEGER"
even though the static is DECLARED i64 and the parameter IS i64. Located 2026-08-01 in
runtime/nx_parse.nx: inject_statics (line ~5187) registers a static as a Local whose `ty`
is the SLOT POINTER *(decl_ty), and the scalar-load path (~line 2690) then loads at L.ty,
producing a POINTER-typed value. The codebase already compensates for this at three
"Static-ptr STRIDE fix" sites (2751/3849/4002) for subscripts and field chains; the
call-argument path is the one that was never fixed.
COST OF THE DEFECT, MEASURED: it made nx_browser (1,810,737 B) and nishi (1,129,654 B)
UNBUILDABLE -- complete working source that nobody could compile -- plus nx_js_conformance,
nx_js_es_census, nx_bugforge and latent instances reachable only by closure reordering
(nx_trimesh.tm_noise3 surfaced in a file nobody edited). Workarounds cost 24 hand casts.
⚠ THIS GATE IS EXPECTED TO BE **RED** UNTIL THE COMPILER IS FIXED. That is its job: T3 is
the defect, and it flips GREEN exactly when the fix lands. A gate that only ever passes
cannot tell you a fix worked.
⚠⚠ WARNING TO WHOEVER FIXES IT -- the obvious one-line fix is UNSAFE and I proved it before
shipping (debt 1785610588). Detecting a static by "ty_kind says scalar but ty.kind is
TY_PTR" MISFIRES ON EVERY POINTER LOCAL: nx_parse.nx:3427 registers an ordinary
`let p: *u8 = ...` as add_local(P, name, v, 0, TY_I64, let_ty) -- the IDENTICAL shape.
That change would silently unwrap every pointer load in the language. The defect fails
LOUDLY at parse; that fix would miscompile SILENTLY. Statics differ only in that value_id
is an IR global rather than an alloca, which the Local struct does not expose -- so a
correct fix needs a new is_static field or an IR is-global query.
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 only when the fix lands.
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 35 | const PG_BUF: i64 = 65536 |
| 36 | const PG_MODE: i64 = 420 |
functions
| 42 | func pg_write(path: *u8, body: *u8) -> i64 |
| 53 | func pg_compile() -> i64 |
| 70 | func pg_case(name: *u8, src: *u8, body: *u8, want_ok: i64, ctr: *i64) -> i64 |
| 84 | func main(argc: i64, argv: *i64) -> i64 |