Multi-shot delimited continuations: 868/870 passing
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 9m5s

Continuations are now multi-shot — k can be invoked multiple times.
Each invocation runs the captured frames via nested cek-run and
returns the result to the caller's continuation.

Fix: continue-with-call runs ONLY the captured delimited frames
(not rest-kont), so the continuation terminates and returns rather
than escaping to the outer program.

Fixed 4 continuation tests:
- shift with multiple invokes: (list (k 10) (k 20)) → (11 21)
- k returned from reset: continuation callable after escaping
- invoke k multiple times: same k reusable
- k in data structure: store in list, retrieve, invoke

Remaining 2 failures: scope/provide across shift boundaries.
These need scope state tracked in frames (not imperative push/pop).

JS 747/747, Full 868/870, Python 679/679.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 14:20:31 +00:00
parent c6a662c980
commit 719da7914e
3 changed files with 146 additions and 12 deletions

View File

@@ -2101,13 +2101,17 @@
(define continue-with-call
(fn (f args env raw-args kont)
(cond
;; Continuation — restore captured frames and inject value
;; Continuation — run captured delimited continuation, return result to caller.
;; Multi-shot: each invocation runs captured frames to completion via nested
;; cek-run, then returns the result to the caller's kont.
(continuation? f)
(let ((arg (if (empty? args) nil (first args)))
(cont-data (continuation-data f)))
(let ((captured (get cont-data "captured"))
(rest-k (get cont-data "rest-kont")))
(make-cek-value arg env (concat captured rest-k))))
(let ((captured (get cont-data "captured")))
;; Run ONLY the captured frames (delimited by reset).
;; Empty kont after captured = the continuation terminates and returns.
(let ((result (cek-run (make-cek-value arg env captured))))
(make-cek-value result env kont))))
;; Native callable
(and (callable? f) (not (lambda? f)) (not (component? f)) (not (island? f)))