From db2e916904b2066144d4f449a54da786a4bbdf56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= <bkchr@users.noreply.github.com> Date: Thu, 30 Apr 2020 14:01:48 +0200 Subject: [PATCH] We should panic on division by zero (#5844) --- substrate/primitives/arithmetic/src/fixed64.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/substrate/primitives/arithmetic/src/fixed64.rs b/substrate/primitives/arithmetic/src/fixed64.rs index 63a69e66e7c..819982aa502 100644 --- a/substrate/primitives/arithmetic/src/fixed64.rs +++ b/substrate/primitives/arithmetic/src/fixed64.rs @@ -167,8 +167,7 @@ impl ops::Div for Fixed64 { fn div(self, rhs: Self) -> Self::Output { if rhs.0 == 0 { - let zero = 0; - return Fixed64::from_parts( self.0 / zero); + panic!("attempt to divide by zero"); } let (n, d) = if rhs.0 < 0 { (-self.0, rhs.0.abs() as u64) -- GitLab