merge: bugs/resume-letrec — cek_run propagates IO suspension via hook
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 27s

This commit is contained in:
2026-05-07 11:27:04 +00:00
5 changed files with 275 additions and 4 deletions

View File

@@ -614,7 +614,7 @@ and cek_step_loop state =
(* cek-run *)
and cek_run state =
(let final = (cek_step_loop (state)) in (if sx_truthy ((cek_suspended_p (final))) then (raise (Eval_error (value_to_str (String "IO suspension in non-IO context")))) else (cek_value (final))))
(let final = (cek_step_loop (state)) in (if sx_truthy ((cek_suspended_p (final))) then (match !_cek_io_suspend_hook with Some hook -> hook final | None -> (raise (Eval_error (value_to_str (String "IO suspension in non-IO context"))))) else (cek_value (final))))
(* cek-resume *)
and cek_resume suspended_state result' =
@@ -1052,7 +1052,14 @@ let cek_run_iterative state =
s := cek_step !s
done;
(match cek_suspended_p !s with
| Bool true -> raise (Eval_error "IO suspension in non-IO context")
| Bool true ->
(* Propagate suspension via the OCaml-side hook so it converts to
VmSuspended and flows to the outer driver (value_to_js / resume
callback). Without the hook (pure CEK harness), keep the legacy
error so test runners surface the misuse. *)
(match !_cek_io_suspend_hook with
| Some hook -> hook !s
| None -> raise (Eval_error "IO suspension in non-IO context"))
| _ -> cek_value !s)
with Eval_error msg ->
_last_error_kont_ref := cek_kont !s;