authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-05-30 04:57:30-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:57-07:00
log6b81546454f925807d2298a127458741be7239e9
treed9ed66fc000683bb8f9fb99993911d84aaaf7bdb
parent494d4f9b8e54b3a0f6c452e1b7dd28e50dd1e6c0

Type: fix `@typeName` for `undefined`


1 files changed, 45 insertions(+), 1 deletions(-)

src/type.zig+45-1
...@@ -288,7 +288,51 @@ pub const Type = struct {...@@ -288,7 +288,51 @@ pub const Type = struct {
288 }288 }
289 try writer.writeAll("}");289 try writer.writeAll("}");
290 },290 },
291 .simple_type => |s| return writer.writeAll(@tagName(s)),291 .simple_type => |s| switch (s) {
292 .f16,
293 .f32,
294 .f64,
295 .f80,
296 .f128,
297 .usize,
298 .isize,
299 .c_char,
300 .c_short,
301 .c_ushort,
302 .c_int,
303 .c_uint,
304 .c_long,
305 .c_ulong,
306 .c_longlong,
307 .c_ulonglong,
308 .c_longdouble,
309 .anyopaque,
310 .bool,
311 .void,
312 .type,
313 .anyerror,
314 .comptime_int,
315 .comptime_float,
316 .noreturn,
317 => return writer.writeAll(@tagName(s)),
318 .null,
319 .undefined,
320 => try writer.print("@TypeOf({s})", .{@tagName(s)}),
321 .enum_literal => try writer.print("@TypeOf(.{s})", .{@tagName(s)}),
322 .atomic_order,
323 .atomic_rmw_op,
324 .calling_convention,
325 .address_space,
326 .float_mode,
327 .reduce_op,
328 .call_modifier,
329 .prefetch_options,
330 .export_options,
331 .extern_options,
332 .type_info,
333 .generic_poison,
334 => unreachable,
335 },
292 .struct_type => |struct_type| {336 .struct_type => |struct_type| {
293 if (mod.structPtrUnwrap(struct_type.index)) |struct_obj| {337 if (mod.structPtrUnwrap(struct_type.index)) |struct_obj| {
294 const decl = mod.declPtr(struct_obj.owner_decl);338 const decl = mod.declPtr(struct_obj.owner_decl);