From 51b04be1ab77a59662b480e1a4351cf19bc6213a Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Sun, 1 Oct 2023 15:03:37 -0500 Subject: [PATCH] :bug: bug: PUC Lua says divides always make floats, even int / int --- src/state.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/state.rs b/src/state.rs index 3592004..fc44dac 100644 --- a/src/state.rs +++ b/src/state.rs @@ -391,19 +391,11 @@ impl <'a> State <'a> { let v_b = self.reg (*b); let v_c = self.reg (*c); - let x = if let (Some (v_b), Some (v_c)) = (v_b.as_int (), v_c.as_int ()) - { - Value::from (v_b / v_c) - } - else { - let v_b = v_b.as_float ().unwrap_or_else (|| panic! ("{v_b}")); - - let v_c = v_c.as_float ().ok_or_else (|| make_step_error ("C must be a number"))?; - - Value::from (v_b / v_c) - }; + let v_b = v_b.as_float ().unwrap_or_else (|| panic! ("{v_b}")); - *self.reg_mut (*a) = x; + let v_c = v_c.as_float ().ok_or_else (|| make_step_error ("C must be a number"))?; + + *self.reg_mut (*a) = Value::from (v_b / v_c); }, Instruction::EqI (a, sb, k_flag) => { if (self.reg (*a).as_int ().unwrap () == *sb as i64) != *k_flag