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
This commit is contained in:
Pierre Tachoire
2025-04-22 09:14:03 +02:00
committed by GitHub

View File

@@ -1403,6 +1403,13 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
return @constCast(@as(*const T, &.{}));
}
// if it isn't an empty struct, then the v8.Object should have an
// InternalFieldCount > 0, since our toa pointer should be embedded
// at index 0 of the internal field count.
if (js_obj.internalFieldCount() == 0) {
return error.InvalidArgument;
}
const type_name = @typeName(T);
if (@hasField(TypeLookup, type_name) == false) {
@compileError(std.fmt.comptimePrint(