Actually fix test for non-booleans

This commit is contained in:
Sofia 2026-03-22 00:34:26 +02:00
parent 8299a64dde
commit af14f482f2

View File

@ -723,15 +723,12 @@ impl<UserData: Clone> ClosureRunner<UserData> {
return Ok(None); return Ok(None);
} }
Instruction::Test(a, b, c) => { Instruction::Test(a, b, c) => {
let is_true = match self let value = self
.stack .stack
.get(b) .get(b)
.map(|v| v.borrow().clone()) .map(|v| v.borrow().clone())
.unwrap_or(Value::Nil) .unwrap_or(Value::Nil);
{ let is_true = (value.is_truthy() as u16) == *c;
Value::Boolean(val) => (val.0 as u16) == *c,
_ => (false as u16) == *c,
};
if is_true { if is_true {
let b = self.get_stack(*b); let b = self.get_stack(*b);
self.set_stack(*a, b); self.set_stack(*a, b);