Fix multi-body lambda in evaluator, rebuild sx_ref.py with router module

evaluator.py _sf_lambda used only expr[2] (first body expression) instead
of collecting all body expressions and wrapping in (begin ...) when multiple.
This caused multi-body lambdas to silently discard all but the first expression.

Rebuilt sx_ref.py with --spec-modules deps,router,engine,signals so the
router functions are available from the bootstrapped code. The test runner
already had _load_router_from_bootstrap() but it was falling back to the
hand-written evaluator (which has set! scoping issues) because the router
functions weren't in sx_ref.py. Now 134/134 eval+router tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 04:34:17 +00:00
parent 5d3676d751
commit 46cd179703
2 changed files with 174 additions and 1 deletions

View File

@@ -487,7 +487,9 @@ def _sf_lambda(expr: list, env: dict) -> Lambda:
param_names.append(p)
else:
raise EvalError(f"Invalid lambda param: {p}")
return Lambda(param_names, expr[2], dict(env))
body_exprs = expr[2:]
body = body_exprs[0] if len(body_exprs) == 1 else [Symbol("begin")] + body_exprs
return Lambda(param_names, body, dict(env))
def _sf_define(expr: list, env: dict) -> Any: