| ... | ... | @@ -723,7 +723,9 @@ fn formatIntUnsigned( |
| 723 | 723 | // max_int_digits accounts for the minus sign. when printing an unsigned |
| 724 | 724 | // number we don't need to do that. |
| 725 | 725 | var buf: [max_int_digits - 1]u8 = undefined; |
| 726 | | var a = if (@sizeOf(@typeOf(value)) == 1) u8(value) else value; |
| 726 | const min_int_bits = comptime math.max(@typeOf(value).bit_count, @typeOf(base).bit_count); |
| 727 | const MinInt = @IntType(@typeOf(value).is_signed, min_int_bits); |
| 728 | var a: MinInt = value; |
| 727 | 729 | var index: usize = buf.len; |
| 728 | 730 | |
| 729 | 731 | while (true) { |
| ... | ... | @@ -965,6 +967,14 @@ test "fmt.format" { |
| 965 | 967 | try testFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", value); |
| 966 | 968 | try testFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", &value); |
| 967 | 969 | } |
| 970 | { |
| 971 | const Struct = struct { |
| 972 | a: u0, |
| 973 | b: u1, |
| 974 | }; |
| 975 | const value = Struct{ .a = 0, .b = 1 }; |
| 976 | try testFmt("struct: Struct{ .a = 0, .b = 1 }\n", "struct: {}\n", value); |
| 977 | } |
| 968 | 978 | { |
| 969 | 979 | const Enum = enum { |
| 970 | 980 | One, |