diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 8bd75e4a90..be00893918 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -651,23 +651,6 @@ void Identifier::dump(int indent) const Value AssignmentExpression::execute(Interpreter& interpreter) const { - AK::Function commit; - if (m_lhs->is_identifier()) { - commit = [&](Value value) { - auto name = static_cast(*m_lhs).string(); - interpreter.set_variable(name, value); - }; - } else if (m_lhs->is_member_expression()) { - commit = [&](Value value) { - if (auto* object = static_cast(*m_lhs).object().execute(interpreter).to_object(interpreter.heap())) { - auto property_name = static_cast(*m_lhs).computed_property_name(interpreter); - object->put(property_name, value); - } - }; - } else { - ASSERT_NOT_REACHED(); - } - auto rhs_result = m_rhs->execute(interpreter); if (interpreter.exception()) return {}; @@ -690,7 +673,19 @@ Value AssignmentExpression::execute(Interpreter& interpreter) const } if (interpreter.exception()) return {}; - commit(rhs_result); + + if (m_lhs->is_identifier()) { + auto name = static_cast(*m_lhs).string(); + interpreter.set_variable(name, rhs_result); + } else if (m_lhs->is_member_expression()) { + if (auto* object = static_cast(*m_lhs).object().execute(interpreter).to_object(interpreter.heap())) { + auto property_name = static_cast(*m_lhs).computed_property_name(interpreter); + object->put(property_name, rhs_result); + } + } else { + ASSERT_NOT_REACHED(); + } + return rhs_result; }