Fix: replace guard with cek-try in test runner, clear stale reuse_stack
The guard form (call/cc + handler-bind expansion) doesn't survive async IO suspension — the CEK continuation from guard's call/cc captures frames that become invalid after the VM resumes from hs-wait. Replacing guard with cek-try (which compiles to VM-native OP_PUSH_HANDLER/OP_POP_HANDLER) avoids the CEK boundary crossing. The test runner now executes: suspends on hs-wait, resumes, runs test actions, and test assertions fire correctly. The "Not callable: nil" error is eliminated. Remaining: test assertion errors from iframe content not loading fast enough (timing issue, not a framework bug). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -854,11 +854,12 @@ let resume_vm vm result =
|
||||
(try run vm
|
||||
with VmSuspended _ as e ->
|
||||
(* Re-suspension during resume: the VM hit another perform.
|
||||
Clear reuse_stack — these entries are stale from the PREVIOUS
|
||||
suspension and don't apply to the current VM frame state.
|
||||
The new VmSuspended carries the current VM state correctly. *)
|
||||
vm.reuse_stack <- [];
|
||||
The new VmSuspended carries the current VM state. *)
|
||||
raise e);
|
||||
(* Clear reuse_stack — any entries here are stale from the original
|
||||
suspension and don't apply to the current state. The VM just
|
||||
completed its execution successfully. *)
|
||||
vm.reuse_stack <- [];
|
||||
(* Restore call_closure_reuse continuations saved during suspension.
|
||||
reuse_stack is in catch order (outermost first from prepend) —
|
||||
reverse to get innermost first, matching callback→caller unwinding. *)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1792,7 +1792,7 @@
|
||||
blake2_js_for_wasm_create: blake2_js_for_wasm_create};
|
||||
}
|
||||
(globalThis))
|
||||
({"link":[["runtime-0db9b496",0],["prelude-d7e4b000",0],["stdlib-23ce0836",[]],["re-9a0de245",[2]],["sx-7f504b3c",[2,3]],["jsoo_runtime-f96b44a8",[2]],["js_of_ocaml-651f6707",[2,5]],["dune__exe__Sx_browser-b285d4f3",[2,4,6]],["std_exit-10fb8830",[2]],["start-f808dbe1",0]],"generated":(b=>{var
|
||||
({"link":[["runtime-0db9b496",0],["prelude-d7e4b000",0],["stdlib-23ce0836",[]],["re-9a0de245",[2]],["sx-267801d6",[2,3]],["jsoo_runtime-f96b44a8",[2]],["js_of_ocaml-651f6707",[2,5]],["dune__exe__Sx_browser-b285d4f3",[2,4,6]],["std_exit-10fb8830",[2]],["start-f808dbe1",0]],"generated":(b=>{var
|
||||
c=b,a=b?.module?.export||b;return{"env":{"caml_ba_kind_of_typed_array":()=>{throw new
|
||||
Error("caml_ba_kind_of_typed_array not implemented")},"caml_exn_with_js_backtrace":()=>{throw new
|
||||
Error("caml_exn_with_js_backtrace not implemented")},"caml_int64_create_lo_mi_hi":()=>{throw new
|
||||
|
||||
@@ -105,13 +105,11 @@
|
||||
(reset! current (str "Running: " name))
|
||||
(reset! results (assoc (deref results) name "running"))
|
||||
(reload-frame)
|
||||
(guard
|
||||
(e
|
||||
(true
|
||||
(reset! results (assoc (deref results) name "fail"))
|
||||
(console-log (str "FAIL " name ": " e))))
|
||||
(for-each run-action (get test :actions))
|
||||
(reset! results (assoc (deref results) name "pass")))))
|
||||
(let
|
||||
((test-ok (cek-try (fn () (for-each run-action (get test :actions)) true) (fn (e) (do (reset! results (assoc (deref results) name "fail")) (console-log (str "FAIL " name ": " e)) false)))))
|
||||
(when
|
||||
test-ok
|
||||
(reset! results (assoc (deref results) name "pass"))))))
|
||||
tests)
|
||||
(reset! running false)
|
||||
(reset! current "Done"))))
|
||||
|
||||
Reference in New Issue
Block a user