diff --git a/src/fd.zig b/src/fd.zig index 46bbbb7676..decafe284f 100644 --- a/src/fd.zig +++ b/src/fd.zig @@ -303,11 +303,6 @@ pub const FDImpl = packed struct { } pub fn format(this: FDImpl, comptime fmt: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - if (fmt.len == 1 and fmt[0] == 'd') { - try writer.print("{d}", .{this.system()}); - return; - } - if (fmt.len != 0) { @compileError("invalid format string for FDImpl.format. must be either '' or 'd'"); } @@ -316,6 +311,12 @@ pub const FDImpl = packed struct { try writer.writeAll("[invalid_fd]"); return; } + + if (fmt.len == 1 and fmt[0] == 'd') { + try writer.print("{d}", .{this.system()}); + return; + } + switch (env.os) { else => { const fd = this.system();