1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:48:13 +00:00

AK+Everywhere: Make Variant::visit() respect the Variant's constness

...and fix all the instances of visit() taking non-const arguments.
This commit is contained in:
Ali Mohammad Pur 2022-01-13 17:31:00 +03:30 committed by Ali Mohammad Pur
parent d55c130df5
commit 9de33629da
7 changed files with 44 additions and 31 deletions

View file

@ -2507,7 +2507,7 @@ Completion AssignmentExpression::execute(Interpreter& interpreter, GlobalObject&
// AssignmentExpression : LeftHandSideExpression = AssignmentExpression
return m_lhs.visit(
// 1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, then
[&](NonnullRefPtr<Expression>& lhs) -> ThrowCompletionOr<Value> {
[&](NonnullRefPtr<Expression> const& lhs) -> ThrowCompletionOr<Value> {
// a. Let lref be the result of evaluating LeftHandSideExpression.
// b. ReturnIfAbrupt(lref).
auto reference = TRY(lhs->to_reference(interpreter, global_object));
@ -2534,7 +2534,7 @@ Completion AssignmentExpression::execute(Interpreter& interpreter, GlobalObject&
return rhs_result;
},
// 2. Let assignmentPattern be the AssignmentPattern that is covered by LeftHandSideExpression.
[&](NonnullRefPtr<BindingPattern>& pattern) -> ThrowCompletionOr<Value> {
[&](NonnullRefPtr<BindingPattern> const& pattern) -> ThrowCompletionOr<Value> {
// 3. Let rref be the result of evaluating AssignmentExpression.
// 4. Let rval be ? GetValue(rref).
auto rhs_result = TRY(m_rhs->execute(interpreter, global_object)).release_value();