Commit c947e79d73

clickingbuttons <clickingbuttons@pm.me>
2024-04-22 20:02:32
std.meta: give TagPayloadByName unreachable a better @compileError message
1 parent 8af59d1
Changed files (1)
lib
lib/std/meta.zig
@@ -719,7 +719,7 @@ pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
             return field_info.type;
     }
 
-    unreachable;
+    @compileError("no field '" ++ tag_name ++ "' in union '" ++ @typeName(U) ++ "'");
 }
 
 /// Given a tagged union type, and an enum, return the type of the union field