| ... | @@ -148,7 +148,6 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { | ... | @@ -148,7 +148,6 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { |
| 148 | self.popState(); | 148 | self.popState(); |
| 149 | } | 149 | } |
| 150 | | 150 | |
| 151 | // TODO better handling of ComptimeInt and ComptimeFloat | | |
| 152 | pub fn emitNumber( | 151 | pub fn emitNumber( |
| 153 | self: *Self, | 152 | self: *Self, |
| 154 | /// An integer, float, or `std.math.BigInt`. Emitted as a bare number if it fits losslessly | 153 | /// An integer, float, or `std.math.BigInt`. Emitted as a bare number if it fits losslessly |
| ... | @@ -169,8 +168,11 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { | ... | @@ -169,8 +168,11 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { |
| 169 | return; | 168 | return; |
| 170 | } | 169 | } |
| 171 | }, | 170 | }, |
| 172 | .Float => if (@floatCast(f64, value) == value) { | 171 | .ComptimeInt => { |
| 173 | try self.stream.print("{}", .{value}); | 172 | return self.emitNumber(@as(std.math.IntFittingRange(value, value), value)); |
| | 173 | }, |
| | 174 | .Float, .ComptimeFloat => if (@floatCast(f64, value) == value) { |
| | 175 | try self.stream.print("{}", .{@floatCast(f64, value)}); |
| 174 | self.popState(); | 176 | self.popState(); |
| 175 | return; | 177 | return; |
| 176 | }, | 178 | }, |