From 38c6fa9c7610d081e5c9b393286eed2d8a51c8a9 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Thu, 22 May 2025 13:02:08 +0800 Subject: [PATCH] Don't error when failing to convert type to function. Because jsValueToStruct is now used in union probing, it shouldn't fail on a mismatch, but rather return null. It's up to the caller to decide whether that's an error or not. --- src/runtime/js.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/runtime/js.zig b/src/runtime/js.zig index 1e1e6c6f..2d763728 100644 --- a/src/runtime/js.zig +++ b/src/runtime/js.zig @@ -910,7 +910,6 @@ pub fn Env(comptime State: type, comptime WebApis: type) type { // compatible with. A compatible field has higher precedence // than a coercible, but still isn't a perfect match. var compatible_index: ?usize = null; - inline for (u.fields, 0..) |field, i| { switch (try self.probeJsValueToZig(named_function, field.type, js_value)) { .value => |v| return @unionInit(T, field.name, v), @@ -949,7 +948,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type { fn jsValueToStruct(self: *Scope, comptime named_function: NamedFunction, comptime T: type, js_value: v8.Value) !?T { if (@hasDecl(T, "_FUNCTION_ID_KLUDGE")) { if (!js_value.isFunction()) { - return error.InvalidArgument; + return null; } const func = v8.Persistent(v8.Function).init(self.isolate, js_value.castTo(v8.Function));