From 551318910b25063ec2a42dcac0a2d0ae3f2d0a75 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 23 Jul 2023 14:27:14 -0300 Subject: [PATCH] Update EvalIfExpression.php --- src/Evaluator/EvalIfExpression.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Evaluator/EvalIfExpression.php b/src/Evaluator/EvalIfExpression.php index d316adf..67f1429 100644 --- a/src/Evaluator/EvalIfExpression.php +++ b/src/Evaluator/EvalIfExpression.php @@ -24,8 +24,13 @@ public function __invoke(IfExpression $ifExpression): MonkeyObject return match (true) { $monkeyObject instanceof ErrorObject => $monkeyObject, - (bool)$monkeyObject->value => $this->evaluator->eval($ifExpression->consequence, $this->environment), - $ifExpression->alternative instanceof BlockStatement => $this->evaluator->eval($ifExpression->alternative, $this->environment), + + (bool)$monkeyObject->value() => + $this->evaluator->eval($ifExpression->consequence, $this->environment), + + $ifExpression->alternative instanceof BlockStatement => + $this->evaluator->eval($ifExpression->alternative, $this->environment), + default => NullObject::instance(), }; }