diff --git a/hosts/ocaml/lib/sx_runtime.ml b/hosts/ocaml/lib/sx_runtime.ml index 5468e17..bce3212 100644 --- a/hosts/ocaml/lib/sx_runtime.ml +++ b/hosts/ocaml/lib/sx_runtime.ml @@ -102,7 +102,8 @@ let get_val container key = | Dict d, Keyword k -> dict_get d k | (List l | ListRef { contents = l }), Number n -> (try List.nth l (int_of_float n) with _ -> Nil) - | _ -> raise (Eval_error ("get: unsupported " ^ type_of container ^ " / " ^ type_of key)) + | Nil, _ -> Nil (* nil.anything → nil *) + | _, _ -> Nil (* type mismatch → nil (matches JS/Python behavior) *) (** Register get as a primitive override — transpiled code calls (get d k). *) let () = diff --git a/hosts/ocaml/lib/sx_vm.ml b/hosts/ocaml/lib/sx_vm.ml index c6f1f85..0161553 100644 --- a/hosts/ocaml/lib/sx_vm.ml +++ b/hosts/ocaml/lib/sx_vm.ml @@ -381,13 +381,7 @@ and call_closure cl args globals = List.iter (fun a -> push vm a) args; for _ = List.length args to cl.vm_code.vc_locals - 1 do push vm Nil done; vm.frames <- [frame]; - (try run vm - with e -> - Printf.eprintf "[vm-call-closure] FAIL in %s: %s (bc_len=%d args=%d sp=%d)\n%!" - (match cl.vm_name with Some n -> n | None -> "?") - (Printexc.to_string e) - (Array.length cl.vm_code.vc_bytecode) (List.length args) vm.sp; - raise e); + (try run vm with e -> raise e); pop vm (** Execute a compiled module (top-level bytecode). *)