From 42be51609b82675c8df4bdfdade209c4dacc8721 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 11 Apr 2023 21:39:46 +0200 Subject: [PATCH] Remove support for number / ratio If `1 * 40%` and `1 / 40%` both work, then I would expect `1cm * 40%` and `1cm / 40%` to work, too. So the result of both multiplication and division is always the left type. Same with `100% * 40%`. But `100% / 40%` does not return a ratio, it returns a float. This breaks the consistency. For this reason, I am removing support for just the new divisions for now, but we can revisit this. --- src/eval/ops.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/eval/ops.rs b/src/eval/ops.rs index 91160c0de..963c828bd 100644 --- a/src/eval/ops.rs +++ b/src/eval/ops.rs @@ -215,10 +215,8 @@ pub fn div(lhs: Value, rhs: Value) -> StrResult { Ok(match (lhs, rhs) { (Int(a), Int(b)) => Float(a as f64 / b as f64), (Int(a), Float(b)) => Float(a as f64 / b), - (Int(a), Ratio(b)) => Float(a as f64 / b), (Float(a), Int(b)) => Float(a / b as f64), (Float(a), Float(b)) => Float(a / b), - (Float(a), Ratio(b)) => Float(a / b), (Length(a), Int(b)) => Length(a / b as f64), (Length(a), Float(b)) => Length(a / b),