pattern: Fixed control flow statements not being applied correctly

This commit is contained in:
WerWolv
2022-02-11 21:02:18 +01:00
parent 57f31123e7
commit 585058b500
2 changed files with 11 additions and 9 deletions

View File

@@ -2281,16 +2281,15 @@ namespace hex::pl {
FunctionResult execute(Evaluator *evaluator) const override {
auto returnValue = this->getReturnValue();
auto literal = dynamic_cast<ASTNodeLiteral *>(returnValue->evaluate(evaluator));
ON_SCOPE_EXIT { delete literal; };
evaluator->setCurrentControlFlowStatement(this->m_type);
if (returnValue == nullptr)
if (literal == nullptr)
return std::nullopt;
else {
auto literal = dynamic_cast<ASTNodeLiteral *>(returnValue->evaluate(evaluator));
ON_SCOPE_EXIT { delete literal; };
else
return literal->getValue();
}
}
private: