aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-05-30 04:57:30 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:57 -0700
commit6b81546454f925807d2298a127458741be7239e9 (patch)
treed9ed66fc000683bb8f9fb99993911d84aaaf7bdb /src/type.zig
parent494d4f9b8e54b3a0f6c452e1b7dd28e50dd1e6c0 (diff)
downloadzig-6b81546454f925807d2298a127458741be7239e9.tar.gz
zig-6b81546454f925807d2298a127458741be7239e9.zip
Type: fix `@typeName` for `undefined`
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/type.zig b/src/type.zig
index 0ce242b616..f285caff95 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -288,7 +288,51 @@ pub const Type = struct {
}
try writer.writeAll("}");
},
- .simple_type => |s| return writer.writeAll(@tagName(s)),
+ .simple_type => |s| switch (s) {
+ .f16,
+ .f32,
+ .f64,
+ .f80,
+ .f128,
+ .usize,
+ .isize,
+ .c_char,
+ .c_short,
+ .c_ushort,
+ .c_int,
+ .c_uint,
+ .c_long,
+ .c_ulong,
+ .c_longlong,
+ .c_ulonglong,
+ .c_longdouble,
+ .anyopaque,
+ .bool,
+ .void,
+ .type,
+ .anyerror,
+ .comptime_int,
+ .comptime_float,
+ .noreturn,
+ => return writer.writeAll(@tagName(s)),
+ .null,
+ .undefined,
+ => try writer.print("@TypeOf({s})", .{@tagName(s)}),
+ .enum_literal => try writer.print("@TypeOf(.{s})", .{@tagName(s)}),
+ .atomic_order,
+ .atomic_rmw_op,
+ .calling_convention,
+ .address_space,
+ .float_mode,
+ .reduce_op,
+ .call_modifier,
+ .prefetch_options,
+ .export_options,
+ .extern_options,
+ .type_info,
+ .generic_poison,
+ => unreachable,
+ },
.struct_type => |struct_type| {
if (mod.structPtrUnwrap(struct_type.index)) |struct_obj| {
const decl = mod.declPtr(struct_obj.owner_decl);