From b346d48572c99f809913cced8910a04d6699701d Mon Sep 17 00:00:00 2001 From: Evin Yulo Date: Sun, 16 Oct 2022 05:31:29 +0000 Subject: [PATCH] Simplify code in std.meta.isTag --- lib/std/meta.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 2644752db7..67de0cd63d 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -68,7 +68,7 @@ pub fn isTag(tagged_value: anytype, comptime tag_name: []const u8) bool { const type_name = @typeName(T); // select the Enum type out of the type (in the case of the tagged union, extract it) - const E = if (.Enum == type_info) T else if (.Union == type_info) (if (type_info.Union.tag_type) |TT| TT else { + const E = if (.Enum == type_info) T else if (.Union == type_info) (type_info.Union.tag_type orelse { @compileError("attempted to use isTag on the untagged union " ++ type_name); }) else { @compileError("attempted to use isTag on a value of type (" ++ type_name ++ ") that isn't an enum or a union.");