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
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:
@@ -453,11 +453,10 @@
|
||||
;; trampoline = (val) → if thunk? then eval-expr(thunk-expr, thunk-env) else val
|
||||
;; All evaluation goes through the CEK machine.
|
||||
|
||||
;; eval-expr: forward declaration — redefined at end of file after cek-run exists.
|
||||
;; This stub is needed so functions between here and Part 3 can reference eval-expr.
|
||||
(define eval-expr
|
||||
(fn (expr (env :as dict))
|
||||
;; Stub — overridden by CEK fixup before any code runs.
|
||||
;; If this executes, CEK fixup failed to load.
|
||||
(error "eval-expr: CEK fixup not loaded")))
|
||||
(fn (expr (env :as dict)) nil))
|
||||
|
||||
|
||||
|
||||
@@ -2470,3 +2469,22 @@
|
||||
(when sx-text
|
||||
(thaw-from-sx sx-text)
|
||||
true))))
|
||||
|
||||
|
||||
;; **************************************************************************
|
||||
;; eval-expr / trampoline — canonical definitions (after cek-run is defined)
|
||||
;; **************************************************************************
|
||||
;;
|
||||
;; These override the forward declarations from Part 2. All evaluation
|
||||
;; goes through the CEK machine. The CEK fixups in the host platform
|
||||
;; may further override these (e.g., to make cek-run iterative).
|
||||
|
||||
(define eval-expr
|
||||
(fn (expr (env :as dict))
|
||||
(cek-run (make-cek-state expr env (list)))))
|
||||
|
||||
(define trampoline
|
||||
(fn (val)
|
||||
(if (thunk? val)
|
||||
(eval-expr (thunk-expr val) (thunk-env val))
|
||||
val)))
|
||||
|
||||
Reference in New Issue
Block a user