Skip to content

Commit 9c4088b

Browse files
committed
We cannot have empty Zig structs mapping to JS instances
An empty struct will share the same address as its sibling (1) which will cause an collision in the identity map. (1) - This depends on Zig's non-guaranteed layout, so the collision might not be with its sibling, but rather some other [seemingly random] field.
1 parent 2815f02 commit 9c4088b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/browser/crypto/crypto.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const uuidv4 = @import("../../id.zig").uuidv4;
2121

2222
// https://w3c.github.io/webcrypto/#crypto-interface
2323
pub const Crypto = struct {
24+
_not_empty: bool = true,
25+
2426
pub fn _getRandomValues(_: *const Crypto, into: RandomValues) !RandomValues {
2527
const buf = into.asBuffer();
2628
if (buf.len > 65_536) {

src/browser/css/css.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pub const Interfaces = .{
2929

3030
// https://developer.mozilla.org/en-US/docs/Web/API/CSS
3131
pub const Css = struct {
32+
_not_empty: bool = true,
33+
3234
pub fn _supports(_: *Css, _: []const u8, _: ?[]const u8) bool {
3335
// TODO: Actually respond with which CSS features we support.
3436
return true;

0 commit comments

Comments
 (0)