Skip to content

Commit 38c6fa9

Browse files
committed
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.
1 parent 3c3de9d commit 38c6fa9

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/runtime/js.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,6 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
910910
// compatible with. A compatible field has higher precedence
911911
// than a coercible, but still isn't a perfect match.
912912
var compatible_index: ?usize = null;
913-
914913
inline for (u.fields, 0..) |field, i| {
915914
switch (try self.probeJsValueToZig(named_function, field.type, js_value)) {
916915
.value => |v| return @unionInit(T, field.name, v),
@@ -949,7 +948,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
949948
fn jsValueToStruct(self: *Scope, comptime named_function: NamedFunction, comptime T: type, js_value: v8.Value) !?T {
950949
if (@hasDecl(T, "_FUNCTION_ID_KLUDGE")) {
951950
if (!js_value.isFunction()) {
952-
return error.InvalidArgument;
951+
return null;
953952
}
954953

955954
const func = v8.Persistent(v8.Function).init(self.isolate, js_value.castTo(v8.Function));

0 commit comments

Comments
 (0)