Here is an example where I'm not 100% on how we upgrade from zig 0.11.0 to 0.13.0.
Docs for the old version
https://ziglang.org/documentation/0.11.0/std/#A;std:math.absInt
Docs for the new builtin I think may be what we want
https://ziglang.org/documentation/0.13.0/#abs
Or maybe one of these
https://ziglang.org/documentation/0.13.0/std/#std.math
const numerator_abs_i128 = math.absInt(numerator_i128) catch {
// Currently, if you try to do multiplication on i64::MIN, panic
// unless you're specifically multiplying by 0 or 1.
//
// Maybe we could support more cases in the future
if (denominator_i128 == one_point_zero_i128) {
return self;
} else {
roc_panic("Decimal division overflow in numerator!", 0);
}
};
/nix/store/xgga5anfp46iafhlrisqqz2b66jw2alb-zig-0.13.0/lib/std/math.zig:1:1: note: struct declared here
const builtin = @import("builtin");
^~~~~
src/dec.zig:1501:20: note: called from here
const result = @call(.always_inline, RocDec.abs, .{arg}) catch {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
comptime_1: src/main.zig:24:20
remaining reference traces hidden; use '-freference-trace' to see all reference traces
src/dec.zig:467:40: error: root struct of file 'math' has no member named 'absInt'
const numerator_abs_i128 = math.absInt(numerator_i128) catch {
~~~~^~~~~~~
Yeah, we want @abs
here.
Instead of erroring on failure, it returns an unsigned type
So i128
becomes a u128
Catching the error will instead happen when we ensure the u128
fits back into an i128
so @abs
follow by if (value < std.math.maxInt(i128)) ...
Last updated: Jul 06 2025 at 12:14 UTC