From acd5ac63b6e16d0b56fa248eb4deb0ce54331ecd Mon Sep 17 00:00:00 2001 From: cirospaciari Date: Thu, 15 Feb 2024 18:36:22 -0300 Subject: [PATCH] we should not crash here --- src/fd.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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();