From 9c4088b24c240468e2ea353a367dc645470ccc98 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 25 Jun 2025 14:58:09 +0800 Subject: [PATCH] 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. --- src/browser/crypto/crypto.zig | 2 ++ src/browser/css/css.zig | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/browser/crypto/crypto.zig b/src/browser/crypto/crypto.zig index bd9eac52..92d4df8c 100644 --- a/src/browser/crypto/crypto.zig +++ b/src/browser/crypto/crypto.zig @@ -21,6 +21,8 @@ const uuidv4 = @import("../../id.zig").uuidv4; // https://w3c.github.io/webcrypto/#crypto-interface pub const Crypto = struct { + _not_empty: bool = true, + pub fn _getRandomValues(_: *const Crypto, into: RandomValues) !RandomValues { const buf = into.asBuffer(); if (buf.len > 65_536) { diff --git a/src/browser/css/css.zig b/src/browser/css/css.zig index 6fda4782..e9d67735 100644 --- a/src/browser/css/css.zig +++ b/src/browser/css/css.zig @@ -29,6 +29,8 @@ pub const Interfaces = .{ // https://developer.mozilla.org/en-US/docs/Web/API/CSS pub const Css = struct { + _not_empty: bool = true, + pub fn _supports(_: *Css, _: []const u8, _: ?[]const u8) bool { // TODO: Actually respond with which CSS features we support. return true;