code wiki / (root) / nx_parse_static_gate.nx

nx_parse_static_gate.nx

buildroot/runtime/nx_parse_static_gate.nx

6541 B130 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/prooftopic parse
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_verdict.nx nx_parse_static_gate.nx

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

main gv_head gv_puts sys_write gv_ctr sys_mmap sys_mmap ↻ pg_case pg_write sys_openat_wr sys_write ↻ sys_close pg_compile sys_fork sys_openat_wr ↻ sys_dup3 sys_execve sys_exit sys_mmap ↻ sys_wait4 gv_check gv_puts ↻ gv_verdict gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻ sys_munmap ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real gv_cat sys_write ↻ sys_close ↻

structs

none

consts

35const PG_BUF: i64 = 65536
36const PG_MODE: i64 = 420

functions

42func pg_write(path: *u8, body: *u8) -> i64
53func pg_compile() -> i64
70func pg_case(name: *u8, src: *u8, body: *u8, want_ok: i64, ctr: *i64) -> i64
called by 1: main calls 3: pg_writepg_compilegv_check
84func main(argc: i64, argv: *i64) -> i64