lumbda/wasm/tests
russell@unturf.com ee5e997df7
wat: internal-define scoping (R7RS letrec*) + c-wasm gc gap documented
WAT — leading (define ...) forms in a lambda body now bind LOCALLY
(letrec*-equivalent) instead of polluting the global env. Implementation:
apply for closures pre-processes the body in three passes:
  1. hoist_internal_defines walks leading defines, env_define each name
     to VOID in the new env, returns the extended env.
  2. strip_leading_defines returns the body with the defines removed.
  3. fill_internal_defines evaluates each define's value-expression in
     the new env (so mutual references work) and env_set the real value.

(define x 1)
(define (f) (define x 99) x)
(f)   ; → 99 (was 99, still 99)
x     ; → 1  (was 99 wrongly — fixed)

(define (h) (define helper (lambda (x) (* x 2))) (helper 5))
helper  ; → unbound (was a leaked global procedure — fixed)

C-WASM — added a thorough doc-block in lumbda_wasm_entry.c covering
the gc.c fallback malloc situation and three plausible real fixes
(Boehm-em build, custom mark-sweep over NaN-boxed heap, generational
reset). Repl tabbar already surfaces the pressure to the user.

Parity corpus locks the new scoping behavior:
  internal-define-local    — global x stays 1
  internal-define-returns  — f returns 99
  internal-define-mutual   — mutually-recursive internal defines

Tests: 20 unit, 8 integration, 11 functional, 249 parity all green.
2026-06-14 17:54:33 -04:00
..
functional-cross.mjs playground+repl: bend dispatch from WASM + 1.33 zoom + free-form runner 2026-06-14 13:05:06 -04:00
functional.mjs wat tier: rationals — (/ 67 7) → 67/7 + arithmetic + reader + printer 2026-06-14 15:11:36 -04:00
integration.mjs playground+repl: bend dispatch from WASM + 1.33 zoom + free-form runner 2026-06-14 13:05:06 -04:00
parity-corpus.mjs wat: internal-define scoping (R7RS letrec*) + c-wasm gc gap documented 2026-06-14 17:54:33 -04:00
parity-cross-tier.mjs parity probe: cross-tier corpus + fix python remainder + asm modulo 2026-06-14 15:21:19 -04:00
unit.mjs playground+repl: bend dispatch from WASM + 1.33 zoom + free-form runner 2026-06-14 13:05:06 -04:00