Type: fix @typeName for undefined

This commit is contained in:
Jacob Young 2023-05-30 04:57:30 -04:00 committed by Andrew Kelley
parent 494d4f9b8e
commit 6b81546454

View File

@ -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);