Skip to content

Commit d8fa9b8

Browse files
committed
Return TypeError if trying to turn an unknown v8.Object into a toa
1 parent 66ec087 commit d8fa9b8

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
@@ -1340,6 +1340,13 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
13401340
return @constCast(@as(*const T, &.{}));
13411341
}
13421342

1343+
// if it isn't an empty struct, then the v8.Object should have an
1344+
// InternalFieldCount > 0, since our toa pointer should be embedded
1345+
// at index 0 of the internal field count.
1346+
if (js_obj.internalFieldCount() == 0) {
1347+
return error.InvalidArgument;
1348+
}
1349+
13431350
const type_name = @typeName(T);
13441351
if (@hasField(TypeLookup, type_name) == false) {
13451352
@compileError(std.fmt.comptimePrint(

0 commit comments

Comments
 (0)