Fix eval-expr stub: define as CEK wrapper, not error stub
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 26m40s

The eval-expr forward declaration was an error-throwing stub that
the CEK fixup was supposed to override. If anything prevented the
fixup from running (or if eval-expr was captured by value before
the fixup), the stub would throw "CEK fixup not loaded".

Fix: define eval-expr and trampoline as real CEK wrappers at the
end of evaluator.sx (after cek-run is defined). The forward
declaration is now a harmless nil-returning stub. The fixup still
overrides with the iterative version, but even without it, eval
works correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 15:08:02 +00:00
parent 9f32c8cf0d
commit 2ef3f03db3
2 changed files with 32 additions and 6 deletions

View File

@@ -14,7 +14,7 @@
// =========================================================================
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
var SX_VERSION = "2026-03-15T14:39:41Z";
var SX_VERSION = "2026-03-15T15:05:23Z";
function isNil(x) { return x === NIL || x === null || x === undefined; }
function isSxTruthy(x) { return x !== false && !isNil(x); }
@@ -1064,7 +1064,7 @@ PRIMITIVES["value-matches-type?"] = valueMatchesType_p;
PRIMITIVES["strict-check-args"] = strictCheckArgs;
// eval-expr
var evalExpr = function(expr, env) { return error("eval-expr: CEK fixup not loaded"); };
var evalExpr = function(expr, env) { return NIL; };
PRIMITIVES["eval-expr"] = evalExpr;
// call-lambda
@@ -2053,6 +2053,14 @@ PRIMITIVES["freeze-to-cid"] = freezeToCid;
})(); };
PRIMITIVES["thaw-from-cid"] = thawFromCid;
// eval-expr
var evalExpr = function(expr, env) { return cekRun(makeCekState(expr, env, [])); };
PRIMITIVES["eval-expr"] = evalExpr;
// trampoline
var trampoline = function(val) { return (isSxTruthy(isThunk(val)) ? evalExpr(thunkExpr(val), thunkEnv(val)) : val); };
PRIMITIVES["trampoline"] = trampoline;
// === Transpiled from render (core) ===