use @hasDecl

This commit is contained in:
Emil Lerch 2026-03-06 09:44:15 -08:00
parent b807ff8768
commit 14d82a13b7
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -459,13 +459,9 @@ pub const Record = struct {
inx = try self.setField(inx, f.name, f.type, f.default_value_ptr, field_val); inx = try self.setField(inx, f.name, f.type, f.default_value_ptr, field_val);
} }
}, },
.@"union" => |info| { .@"union" => {
const active_tag_name = @tagName(val); const active_tag_name = @tagName(val);
comptime var has_decl = false; const key = if (@hasDecl(U, "srf_tag_field"))
inline for (info.decls) |d| {
if (comptime std.mem.eql(u8, "srf_tag_field", d.name)) has_decl = true;
}
const key = if (has_decl)
U.srf_tag_field U.srf_tag_field
else else
"active_tag"; "active_tag";