commit 3a8994a06fa695725fcc6116ba59ae11c0c6732f
parent 0f8eb46eba4f1df0d8f5252bd478fd334962780a
Author: Sylvia Ivory <git@sivory.net>
Date: Thu, 5 Feb 2026 17:58:04 -0800
Fix pubsub errors
Diffstat:
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/shared/pubsub.zig b/shared/pubsub.zig
@@ -84,7 +84,7 @@ pub fn Publisher(comptime M: type) type {
if (std.mem.eql(u8, f.name, @tagName(event))) {
// We know that param_type is a pointer so its safe to index into
if (f.type != @typeInfo(param_type).pointer.child) {
- @compileError("expected " ++ @typeName(f.type) ++ ", found " ++ @typeName(param_type));
+ @compileError("expected *const " ++ @typeName(f.type) ++ ", found " ++ @typeName(param_type));
}
break;
@@ -97,6 +97,19 @@ pub fn Publisher(comptime M: type) type {
}
pub fn publish(self: *Self, comptime event: msg_tag_type, data: anytype) void {
+ comptime {
+ for (msg_union.fields) |f| {
+ if (std.mem.eql(u8, f.name, @tagName(event))) {
+ // We know that param_type is a pointer so its safe to index into
+ if (f.type != @TypeOf(data)) {
+ @compileError("expected " ++ @typeName(f.type) ++ ", found " ++ @typeName(@TypeOf(data)));
+ }
+
+ break;
+ }
+ }
+ }
+
const index = event_map.get(@tagName(event)) orelse unreachable;
const listeners = self.listeners[index];