Skip to content

Commit f3d8ec0

Browse files
Merge pull request #549 from lightpanda-io/type_error_on_non_zig_values
Return TypeError if trying to turn an unknown v8.Object into a toa
2 parents 0a29e9b + d8fa9b8 commit f3d8ec0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/runtime/js.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,13 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
14031403
return @constCast(@as(*const T, &.{}));
14041404
}
14051405

1406+
// if it isn't an empty struct, then the v8.Object should have an
1407+
// InternalFieldCount > 0, since our toa pointer should be embedded
1408+
// at index 0 of the internal field count.
1409+
if (js_obj.internalFieldCount() == 0) {
1410+
return error.InvalidArgument;
1411+
}
1412+
14061413
const type_name = @typeName(T);
14071414
if (@hasField(TypeLookup, type_name) == false) {
14081415
@compileError(std.fmt.comptimePrint(

0 commit comments

Comments
 (0)