From 4d1e85a2959f6ff4c6fbbeb9e232307ae77754d3 Mon Sep 17 00:00:00 2001 From: Erin Date: Thu, 2 Sep 2021 18:35:33 +0200 Subject: [PATCH] Fixed division x/0 is now x/42 instead of 42 which makes it more confusing --- ablescript/src/variables.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index 23fb17a..ca609a8 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -393,14 +393,10 @@ impl ops::Div for Value { }) .collect(), ), - Value::Int(i) => Value::Int({ - let rhsi = rhs.into_i32(); - if rhsi == 0 { - consts::ANSWER - } else { - i.wrapping_div(rhsi) - } - }), + Value::Int(i) => Value::Int(i.wrapping_div(match rhs.into_i32() { + 0 => consts::ANSWER, + rhsi => rhsi, + })), Value::Bool(b) => Value::Bool(!b || rhs.into_bool()), Value::Abool(_) => !self + rhs, Value::Functio(_) => todo!(),