Compiler: proper letrec support (mutual recursion)
The compiler was treating letrec as let — binding values sequentially. This meant mutually recursive functions (like sx-parse's read-list calling read-expr and vice versa) couldn't reference each other. compile-letrec uses two phases: 1. Define all local slots initialized to nil 2. Compile and assign values — all names already in scope This fixes sx-parse producing wrong ASTs (nested instead of sibling lists) when JIT-compiled, which caused the stepper's step count to be 2 instead of 16. Also: skip JIT for lambdas with closure bindings (inner functions like read-list-loop) — the closure merging into vm_env_ref produces incorrect variable resolution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
// =========================================================================
|
||||
|
||||
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
|
||||
var SX_VERSION = "2026-03-23T18:18:45Z";
|
||||
var SX_VERSION = "2026-03-23T18:52:19Z";
|
||||
|
||||
function isNil(x) { return x === NIL || x === null || x === undefined; }
|
||||
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
||||
|
||||
Reference in New Issue
Block a user