Commit c3821fe4ca

mlugg <mlugg@mlugg.co.uk>
2024-11-28 19:29:32
compiler: use `@Type` instead of `@TypeOf` to print enum literal type
1 parent 88d5791
src/Type.zig
@@ -314,7 +314,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
             .undefined,
             => try writer.print("@TypeOf({s})", .{@tagName(s)}),
 
-            .enum_literal => try writer.print("@TypeOf(.{s})", .{@tagName(s)}),
+            .enum_literal => try writer.writeAll("@Type(.enum_literal)"),
 
             .generic_poison => unreachable,
         },
test/cases/compile_errors/attempt_to_cast_enum_literal_to_error.zig
@@ -8,4 +8,4 @@ export fn entry() void {
 // backend=stage2
 // target=native
 //
-// :3:10: error: expected type 'error{Hi}', found '@TypeOf(.enum_literal)'
+// :3:10: error: expected type 'error{Hi}', found '@Type(.enum_literal)'
test/cases/compile_errors/error_set_decl_literal.zig
@@ -6,4 +6,4 @@ export fn entry() void {
 
 // error
 //
-// :3:19: error: expected type 'error{Foo}', found '@TypeOf(.enum_literal)'
+// :3:19: error: expected type 'error{Foo}', found '@Type(.enum_literal)'
test/cases/compile_errors/runtime_condition_comptime_type_in_destructure.zig
@@ -7,4 +7,4 @@ export fn foobar() void {
 
 // error
 //
-// :4:5: error: value with comptime-only type '@TypeOf(.enum_literal)' depends on runtime control flow
+// :4:5: error: value with comptime-only type '@Type(.enum_literal)' depends on runtime control flow