patterns: Evaluate return value before setting control flow type
Fixes another issue mentioned in #460
This commit is contained in:
parent
2c361f9b0a
commit
61d9918dae
@ -34,19 +34,21 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
FunctionResult execute(Evaluator *evaluator) const override {
|
||||
if (this->m_rvalue == nullptr) {
|
||||
evaluator->setCurrentControlFlowStatement(this->m_type);
|
||||
|
||||
if (this->m_rvalue == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
} else {
|
||||
auto returnValue = this->m_rvalue->evaluate(evaluator);
|
||||
auto literal = dynamic_cast<ASTNodeLiteral *>(returnValue.get());
|
||||
|
||||
evaluator->setCurrentControlFlowStatement(this->m_type);
|
||||
|
||||
if (literal == nullptr)
|
||||
return std::nullopt;
|
||||
else
|
||||
return literal->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ControlFlowStatement m_type;
|
||||
|
Loading…
Reference in New Issue
Block a user