Fix get nil-safety in sx_runtime.ml + reduce VM failure log noise

The second get implementation in sx_runtime.ml (used by transpiled code)
was still raising on type mismatches. Now returns nil like sx_primitives.

Remove per-call [vm-call-closure] FAIL logging — the jit-hook already
logs failures at the right level. Reduces 70K log lines to ~5.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 10:20:13 +00:00
parent e12b2eab6b
commit 1cc3e761a2
2 changed files with 3 additions and 8 deletions

View File

@@ -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 () =

View File

@@ -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). *)