patterns: Fixed crash when using control flow statements without value

Fixes #460
This commit is contained in:
WerWolv 2022-03-01 20:17:03 +01:00
parent 2a989c6cc1
commit 775b3e8c52
1 changed files with 6 additions and 4 deletions

View File

@ -34,12 +34,14 @@ namespace hex::pl {
}
FunctionResult execute(Evaluator *evaluator) const override {
auto returnValue = this->m_rvalue->evaluate(evaluator);
auto literal = dynamic_cast<ASTNodeLiteral *>(returnValue.get());
evaluator->setCurrentControlFlowStatement(this->m_type);
if (this->m_rvalue == nullptr)
return std::nullopt;
auto returnValue = this->m_rvalue->evaluate(evaluator);
auto literal = dynamic_cast<ASTNodeLiteral *>(returnValue.get());
if (literal == nullptr)
return std::nullopt;
else