From ffb0050d811ba7c79d7781cc908a499e4c95d4e3 Mon Sep 17 00:00:00 2001 From: snoire Date: Mon, 27 Oct 2025 16:10:20 +0800 Subject: [PATCH 1/2] std.Io.Writer.print: support .enum_literal in 't' format specifier --- lib/std/Io/Writer.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/Io/Writer.zig b/lib/std/Io/Writer.zig index b41aa24ccb3c..d0721307d49d 100644 --- a/lib/std/Io/Writer.zig +++ b/lib/std/Io/Writer.zig @@ -1161,7 +1161,7 @@ pub fn printValue( }, 't' => switch (@typeInfo(T)) { .error_set => return w.alignBufferOptions(@errorName(value), options), - .@"enum", .@"union" => return w.alignBufferOptions(@tagName(value), options), + .@"enum", .enum_literal, .@"union" => return w.alignBufferOptions(@tagName(value), options), else => invalidFmtError(fmt, value), }, else => {}, From b4b54b597d59b709b7d801db55c7705c8e950d4e Mon Sep 17 00:00:00 2001 From: snoire Date: Thu, 6 Nov 2025 13:44:53 +0800 Subject: [PATCH 2/2] test: add test case for enum-literal with '{t}' format Co-authored-by: Ryan Liptak --- lib/std/fmt.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 9a705a439779..2dc7e13855ee 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -1249,6 +1249,7 @@ test "vector" { test "enum-literal" { try expectFmt(".hello_world", "{}", .{.hello_world}); + try expectFmt("hello_world", "{t}", .{.hello_world}); } test "padding" {