Skip to content

Commit 340871f

Browse files
committed
std.math.divCeil: move compile error back down
1 parent 49e67ce commit 340871f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/std/math.zig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,7 @@ fn testDivFloor() void {
623623

624624
pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
625625
@setRuntimeSafety(false);
626-
if (!(comptime std.meta.trait.isNumber(T)))
627-
@compileError("divCeil unsupported on " ++ @typeName(T));
628-
if (denominator == 0)
629-
return error.DivisionByZero;
626+
if (comptime std.meta.trait.isNumber(T) and denominator == 0) return error.DivisionByZero;
630627
const info = @typeInfo(T);
631628
switch (info) {
632629
.ComptimeFloat, .Float => return @ceil(numerator / denominator),
@@ -640,7 +637,7 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
640637
return @divFloor(numerator - 1, denominator) + 1;
641638
return @divTrunc(numerator, denominator);
642639
},
643-
else => unreachable,
640+
else => @compileError("divCeil unsupported on " ++ @typeName(T)),
644641
}
645642
}
646643

0 commit comments

Comments
 (0)