🐛 bug: PUC Lua says divides always make floats, even int / int

main
_ 2023-10-01 15:03:37 -05:00
parent eb024eed3e
commit 51b04be1ab
1 changed files with 4 additions and 12 deletions

View File

@ -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