From 5a8780838fb3fc18f7c7ebfbf164b37032c2f829 Mon Sep 17 00:00:00 2001 From: mlugg Date: Wed, 14 Aug 2024 08:48:31 +0100 Subject: [PATCH] Sema: don't set union tag type if it's not an enum --- src/Sema.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sema.zig b/src/Sema.zig index d760927c4d..dab4262bdd 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -36641,11 +36641,11 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind } } else { // The provided type is the enum tag type. - union_type.setTagType(ip, provided_ty.toIntern()); const enum_type = switch (ip.indexToKey(provided_ty.toIntern())) { .enum_type => ip.loadEnumType(provided_ty.toIntern()), else => return sema.fail(&block_scope, tag_ty_src, "expected enum tag type, found '{}'", .{provided_ty.fmt(pt)}), }; + union_type.setTagType(ip, provided_ty.toIntern()); // The fields of the union must match the enum exactly. // A flag per field is used to check for missing and extraneous fields. explicit_tags_seen = try sema.arena.alloc(bool, enum_type.names.len);