std.json properly handle comptime int/float
This commit is contained in:
@@ -148,7 +148,6 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
|
||||
self.popState();
|
||||
}
|
||||
|
||||
// TODO better handling of ComptimeInt and ComptimeFloat
|
||||
pub fn emitNumber(
|
||||
self: *Self,
|
||||
/// 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 {
|
||||
return;
|
||||
}
|
||||
},
|
||||
.Float => if (@floatCast(f64, value) == value) {
|
||||
try self.stream.print("{}", .{value});
|
||||
.ComptimeInt => {
|
||||
return self.emitNumber(@as(std.math.IntFittingRange(value, value), value));
|
||||
},
|
||||
.Float, .ComptimeFloat => if (@floatCast(f64, value) == value) {
|
||||
try self.stream.print("{}", .{@floatCast(f64, value)});
|
||||
self.popState();
|
||||
return;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user