|
@@ -96,7 +96,7 @@ ThrowCompletionOr<Object*> ProxyObject::internal_get_prototype_of() const
|
|
|
}
|
|
|
|
|
|
// 10.5.2 [[SetPrototypeOf]] ( V ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v
|
|
|
-bool ProxyObject::internal_set_prototype_of(Object* prototype)
|
|
|
+ThrowCompletionOr<bool> ProxyObject::internal_set_prototype_of(Object* prototype)
|
|
|
{
|
|
|
auto& vm = this->vm();
|
|
|
auto& global_object = this->global_object();
|
|
@@ -105,16 +105,14 @@ bool ProxyObject::internal_set_prototype_of(Object* prototype)
|
|
|
// 2. Let handler be O.[[ProxyHandler]].
|
|
|
|
|
|
// 3. If handler is null, throw a TypeError exception.
|
|
|
- if (m_is_revoked) {
|
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::ProxyRevoked);
|
|
|
- return {};
|
|
|
- }
|
|
|
+ if (m_is_revoked)
|
|
|
+ return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked);
|
|
|
|
|
|
// 4. Assert: Type(handler) is Object.
|
|
|
// 5. Let target be O.[[ProxyTarget]].
|
|
|
|
|
|
// 6. Let trap be ? GetMethod(handler, "setPrototypeOf").
|
|
|
- auto trap = TRY_OR_DISCARD(Value(&m_handler).get_method(global_object, vm.names.setPrototypeOf));
|
|
|
+ auto trap = TRY(Value(&m_handler).get_method(global_object, vm.names.setPrototypeOf));
|
|
|
|
|
|
// 7. If trap is undefined, then
|
|
|
if (!trap) {
|
|
@@ -123,7 +121,7 @@ bool ProxyObject::internal_set_prototype_of(Object* prototype)
|
|
|
}
|
|
|
|
|
|
// 8. Let booleanTrapResult be ! ToBoolean(? Call(trap, handler, « target, V »)).
|
|
|
- auto trap_result = TRY_OR_DISCARD(vm.call(*trap, &m_handler, &m_target, prototype)).to_boolean();
|
|
|
+ auto trap_result = TRY(vm.call(*trap, &m_handler, &m_target, prototype)).to_boolean();
|
|
|
|
|
|
// 9. If booleanTrapResult is false, return false.
|
|
|
if (!trap_result)
|
|
@@ -131,21 +129,19 @@ bool ProxyObject::internal_set_prototype_of(Object* prototype)
|
|
|
|
|
|
// 10. Let extensibleTarget be ? IsExtensible(target).
|
|
|
auto extensible_target = m_target.is_extensible();
|
|
|
- if (vm.exception())
|
|
|
- return {};
|
|
|
+ if (auto* exception = vm.exception())
|
|
|
+ return throw_completion(exception->value());
|
|
|
|
|
|
// 11. If extensibleTarget is true, return true.
|
|
|
if (extensible_target)
|
|
|
return true;
|
|
|
|
|
|
// 12. Let targetProto be ? target.[[GetPrototypeOf]]().
|
|
|
- auto* target_proto = TRY_OR_DISCARD(m_target.internal_get_prototype_of());
|
|
|
+ auto* target_proto = TRY(m_target.internal_get_prototype_of());
|
|
|
|
|
|
// 13. If SameValue(V, targetProto) is false, throw a TypeError exception.
|
|
|
- if (!same_value(prototype, target_proto)) {
|
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::ProxySetPrototypeOfNonExtensible);
|
|
|
- return {};
|
|
|
- }
|
|
|
+ if (!same_value(prototype, target_proto))
|
|
|
+ return vm.throw_completion<TypeError>(global_object, ErrorType::ProxySetPrototypeOfNonExtensible);
|
|
|
|
|
|
// 14. Return true.
|
|
|
return true;
|