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...@@ -36641,11 +36641,11 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind
36641 }36641 }
36642 } else {36642 } else {
36643 // The provided type is the enum tag type.36643 // The provided type is the enum tag type.
36644 union_type.setTagType(ip, provided_ty.toIntern());
36645 const enum_type = switch (ip.indexToKey(provided_ty.toIntern())) {36644 const enum_type = switch (ip.indexToKey(provided_ty.toIntern())) {
36646 .enum_type => ip.loadEnumType(provided_ty.toIntern()),36645 .enum_type => ip.loadEnumType(provided_ty.toIntern()),
36647 else => return sema.fail(&block_scope, tag_ty_src, "expected enum tag type, found '{}'", .{provided_ty.fmt(pt)}),36646 else => return sema.fail(&block_scope, tag_ty_src, "expected enum tag type, found '{}'", .{provided_ty.fmt(pt)}),
36648 };36647 };
36648 union_type.setTagType(ip, provided_ty.toIntern());
36649 // The fields of the union must match the enum exactly.36649 // The fields of the union must match the enum exactly.
36650 // A flag per field is used to check for missing and extraneous fields.36650 // A flag per field is used to check for missing and extraneous fields.
36651 explicit_tags_seen = try sema.arena.alloc(bool, enum_type.names.len);36651 explicit_tags_seen = try sema.arena.alloc(bool, enum_type.names.len);