authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-14 08:48:31+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-17 18:50:10-04:00
log5a8780838fb3fc18f7c7ebfbf164b37032c2f829
treeab04b31e0c7bea4040ca0a1c1cb33181d618b09c
parent46388d338a93a35d139866411f80115a03b30a6a

Sema: don't set union tag type if it's not an enum


1 files changed, 1 insertions(+), 1 deletions(-)

src/Sema.zig+1-1
......@@ -36641,11 +36641,11 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind
3664136641 }
3664236642 } else {
3664336643 // The provided type is the enum tag type.
36644 union_type.setTagType(ip, provided_ty.toIntern());
3664536644 const enum_type = switch (ip.indexToKey(provided_ty.toIntern())) {
3664636645 .enum_type => ip.loadEnumType(provided_ty.toIntern()),
3664736646 else => return sema.fail(&block_scope, tag_ty_src, "expected enum tag type, found '{}'", .{provided_ty.fmt(pt)}),
3664836647 };
36648 union_type.setTagType(ip, provided_ty.toIntern());
3664936649 // The fields of the union must match the enum exactly.
3665036650 // A flag per field is used to check for missing and extraneous fields.
3665136651 explicit_tags_seen = try sema.arena.alloc(bool, enum_type.names.len);