🐛 bug: PUC Lua says divides always make floats, even int / int
parent
eb024eed3e
commit
51b04be1ab
14
src/state.rs
14
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_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"))?;
|
||||
let v_c = v_c.as_float ().ok_or_else (|| make_step_error ("C must be a number"))?;
|
||||
|
||||
Value::from (v_b / v_c)
|
||||
};
|
||||
|
||||
*self.reg_mut (*a) = x;
|
||||
*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
|
||||
|
|
Loading…
Reference in New Issue