Closed
Description
Zig Version
0.12.0-dev.3381+7057bffc1
Steps to Reproduce and Observed Behavior
To reproduce run:
pub fn main() !void {
const olength: u32 = 1;
const precision: ?usize = null;
const exponent: i32 = -1;
const req_bytes = 2 + @max(@abs(exponent) + olength, precision orelse 0);
_ = req_bytes;
}
❯ zig run test.zig
test.zig:5:25: error: overflow of integer type 'u2' with value '4'
const req_bytes = 2 + @max(@abs(exponent) + olength, precision orelse 0);
~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is an actual library line:
Line 275 in e831313
It happens only in comptime
Expected Behavior
result type must be u32
or usize
instead of u2