Fixed division

x/0 is now x/42 instead of 42 which makes it more confusing
pull/2/head
ondra05 2021-09-02 18:35:33 +02:00
parent 71e56e9ad4
commit 4c5c44d177
1 changed files with 4 additions and 8 deletions

View File

@ -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!(),