Skip to content

Commit

Permalink
LibJS: Avoid RequireObjectCoercible when creating super references
Browse files Browse the repository at this point in the history
This is part of an old normative change that happened soon after
Andreas made `super` closer to spec in 1270df2.
See tc39/ecma262#2267

This was introduced into bytecode by virtue of copy and paste :^)

Bytecode results:
Summary:
    Diff Tests:
        +2 ✅    -2 ❌
  • Loading branch information
Lubrsi committed Jul 5, 2023
1 parent 9f8416d commit 9b14ea1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions Userland/Libraries/LibJS/Bytecode/Op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,7 @@ ThrowCompletionOr<void> ResolveSuperBase::execute_impl(Bytecode::Interpreter& in
VERIFY(env.has_super_binding());

// 3. Let baseValue be ? env.GetSuperBase().
auto base_value = TRY(env.get_super_base());

// 4. Let bv be ? RequireObjectCoercible(baseValue).
interpreter.accumulator() = TRY(require_object_coercible(vm, base_value));
interpreter.accumulator() = TRY(env.get_super_base());

return {};
}
Expand Down
7 changes: 2 additions & 5 deletions Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,8 @@ ThrowCompletionOr<Reference> make_super_property_reference(VM& vm, Value actual_
// 3. Let baseValue be ? env.GetSuperBase().
auto base_value = TRY(env.get_super_base());

// 4. Let bv be ? RequireObjectCoercible(baseValue).
auto bv = TRY(require_object_coercible(vm, base_value));

// 5. Return the Reference Record { [[Base]]: bv, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: actualThis }.
return Reference { bv, property_key, actual_this, strict };
// 4. Return the Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: actualThis }.
return Reference { base_value, property_key, actual_this, strict };
}

// 19.2.1.1 PerformEval ( x, strictCaller, direct ), https://tc39.es/ecma262/#sec-performeval
Expand Down

0 comments on commit 9b14ea1

Please sign in to comment.