From 340871f06105830087dd8e254e604892f08bccc7 Mon Sep 17 00:00:00 2001 From: Kate Tsuyu Date: Sat, 29 Aug 2020 00:37:10 -0400 Subject: [PATCH] std.math.divCeil: move compile error back down --- lib/std/math.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/std/math.zig b/lib/std/math.zig index a66d47412d..4f640ef652 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -623,10 +623,7 @@ fn testDivFloor() void { pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T { @setRuntimeSafety(false); - if (!(comptime std.meta.trait.isNumber(T))) - @compileError("divCeil unsupported on " ++ @typeName(T)); - if (denominator == 0) - return error.DivisionByZero; + if (comptime std.meta.trait.isNumber(T) and denominator == 0) return error.DivisionByZero; const info = @typeInfo(T); switch (info) { .ComptimeFloat, .Float => return @ceil(numerator / denominator), @@ -640,7 +637,7 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T { return @divFloor(numerator - 1, denominator) + 1; return @divTrunc(numerator, denominator); }, - else => unreachable, + else => @compileError("divCeil unsupported on " ++ @typeName(T)), } }