mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Fixed strFromIntHelp. std.math.minInt is 0 for unsigned types, so buffer size was being set to only 1.
This commit is contained in:
parent
17e5ec85aa
commit
cb3ea8641c
1 changed files with 4 additions and 2 deletions
|
@ -468,8 +468,10 @@ fn strFromIntHelp(comptime T: type, int: T) RocStr {
|
|||
const size = comptime blk: {
|
||||
// the string representation of the minimum i128 value uses at most 40 characters
|
||||
var buf: [40]u8 = undefined;
|
||||
var result = std.fmt.bufPrint(&buf, "{}", .{std.math.minInt(T)}) catch unreachable;
|
||||
break :blk result.len;
|
||||
var resultMin = std.fmt.bufPrint(&buf, "{}", .{std.math.minInt(T)}) catch unreachable;
|
||||
var resultMax = std.fmt.bufPrint(&buf, "{}", .{std.math.maxInt(T)}) catch unreachable;
|
||||
var result = if (resultMin.len > resultMax.len) resultMin.len else resultMax.len;
|
||||
break :blk result;
|
||||
};
|
||||
|
||||
var buf: [size]u8 = undefined;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue