diff --git a/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp b/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp index ce7f400af..0b16559d5 100644 --- a/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp +++ b/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp @@ -34,18 +34,20 @@ namespace hex::pl { } FunctionResult execute(Evaluator *evaluator) const override { - evaluator->setCurrentControlFlowStatement(this->m_type); - - if (this->m_rvalue == nullptr) + if (this->m_rvalue == nullptr) { + evaluator->setCurrentControlFlowStatement(this->m_type); return std::nullopt; + } else { + auto returnValue = this->m_rvalue->evaluate(evaluator); + auto literal = dynamic_cast(returnValue.get()); - auto returnValue = this->m_rvalue->evaluate(evaluator); - auto literal = dynamic_cast(returnValue.get()); + evaluator->setCurrentControlFlowStatement(this->m_type); - if (literal == nullptr) - return std::nullopt; - else - return literal->getValue(); + if (literal == nullptr) + return std::nullopt; + else + return literal->getValue(); + } } private: