authorgravatar for samdembiny@gmail.comconmaster2112 <samdembiny@gmail.com> 2026-09-11 13:05:21+02:00
committergravatar for samdembiny@gmail.comconmaster2112 <samdembiny@gmail.com> 2026-09-11 13:05:21+02:00
log8253b29cc5198a9f2b56b5274d766317efcffccb
tree2051b9109ce7eefe4ee3cf3b4cfd3a1f831bc284
parent0d600e488f005a3823525779eeadf68ea6065427

fix(#36798): nonexhaustive enums are no longer printed as @enumFromInt, but as @fromBackingInt


3 files changed, 3 insertions(+), 3 deletions(-)

lib/std/Io/Writer.zig+1-1
...@@ -1560,7 +1560,7 @@ fn printEnumNonexhaustive(w: *Writer, value: anytype) Error!void {...@@ -1560,7 +1560,7 @@ fn printEnumNonexhaustive(w: *Writer, value: anytype) Error!void {
1560 try w.writeVecAll(&vecs);1560 try w.writeVecAll(&vecs);
1561 return;1561 return;
1562 }1562 }
1563 try w.writeAll("@enumFromInt(");1563 try w.writeAll("@fromBackingInt(");
1564 try w.printInt(@backingInt(value), 10, .lower, .{});1564 try w.printInt(@backingInt(value), 10, .lower, .{});
1565 try w.writeByte(')');1565 try w.writeByte(')');
1566}1566}
lib/std/Target.zig+1-1
...@@ -324,7 +324,7 @@ pub const Os = struct {...@@ -324,7 +324,7 @@ pub const Os = struct {
324 var vecs: [2][]const u8 = .{ ".", name };324 var vecs: [2][]const u8 = .{ ".", name };
325 return w.writeVecAll(&vecs);325 return w.writeVecAll(&vecs);
326 } else {326 } else {
327 return w.print("@enumFromInt(0x{X:0>8})", .{wv});327 return w.print("@fromBackingInt(0x{X:0>8})", .{wv});
328 }328 }
329 }329 }
330 };330 };
lib/std/fmt.zig+1-1
...@@ -947,7 +947,7 @@ test "non-exhaustive enum" {...@@ -947,7 +947,7 @@ test "non-exhaustive enum" {
947 };947 };
948 try expectFmt("enum: .One\n", "enum: {}\n", .{Enum.One});948 try expectFmt("enum: .One\n", "enum: {}\n", .{Enum.One});
949 try expectFmt("enum: .Two\n", "enum: {}\n", .{Enum.Two});949 try expectFmt("enum: .Two\n", "enum: {}\n", .{Enum.Two});
950 try expectFmt("enum: @enumFromInt(4660)\n", "enum: {}\n", .{@as(Enum, @fromBackingInt(@intCast(0x1234)))});950 try expectFmt("enum: @fromBackingInt(4660)\n", "enum: {}\n", .{@as(Enum, @fromBackingInt(@intCast(0x1234)))});
951 try expectFmt("enum: f\n", "enum: {x}\n", .{Enum.One});951 try expectFmt("enum: f\n", "enum: {x}\n", .{Enum.One});
952 try expectFmt("enum: beef\n", "enum: {x}\n", .{Enum.Two});952 try expectFmt("enum: beef\n", "enum: {x}\n", .{Enum.Two});
953 try expectFmt("enum: BEEF\n", "enum: {X}\n", .{Enum.Two});953 try expectFmt("enum: BEEF\n", "enum: {X}\n", .{Enum.Two});