1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:27:44 +00:00

LibJS: Convert set_immutable_prototype() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-10-03 19:52:13 +01:00
parent a7b1c7eb16
commit 0a49a2db60
4 changed files with 5 additions and 4 deletions

View file

@ -841,12 +841,12 @@ ThrowCompletionOr<MarkedValueList> Object::internal_own_property_keys() const
} }
// 10.4.7.2 SetImmutablePrototype ( O, V ), https://tc39.es/ecma262/#sec-set-immutable-prototype // 10.4.7.2 SetImmutablePrototype ( O, V ), https://tc39.es/ecma262/#sec-set-immutable-prototype
bool Object::set_immutable_prototype(Object* prototype) ThrowCompletionOr<bool> Object::set_immutable_prototype(Object* prototype)
{ {
// 1. Assert: Either Type(V) is Object or Type(V) is Null. // 1. Assert: Either Type(V) is Object or Type(V) is Null.
// 2. Let current be ? O.[[GetPrototypeOf]](). // 2. Let current be ? O.[[GetPrototypeOf]]().
auto* current = TRY_OR_DISCARD(internal_get_prototype_of()); auto* current = TRY(internal_get_prototype_of());
// 3. If SameValue(V, current) is true, return true. // 3. If SameValue(V, current) is true, return true.
if (prototype == current) if (prototype == current)

View file

@ -108,7 +108,7 @@ public:
// 10.4.7 Immutable Prototype Exotic Objects, https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects // 10.4.7 Immutable Prototype Exotic Objects, https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects
bool set_immutable_prototype(Object* prototype); ThrowCompletionOr<bool> set_immutable_prototype(Object* prototype);
// 20.1 Object Objects, https://tc39.es/ecma262/#sec-object-objects // 20.1 Object Objects, https://tc39.es/ecma262/#sec-object-objects

View file

@ -55,6 +55,7 @@ ObjectPrototype::~ObjectPrototype()
// 10.4.7.1 [[SetPrototypeOf]] ( V ), https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects-setprototypeof-v // 10.4.7.1 [[SetPrototypeOf]] ( V ), https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects-setprototypeof-v
ThrowCompletionOr<bool> ObjectPrototype::internal_set_prototype_of(Object* prototype) ThrowCompletionOr<bool> ObjectPrototype::internal_set_prototype_of(Object* prototype)
{ {
// 1. Return ? SetImmutablePrototype(O, V).
return set_immutable_prototype(prototype); return set_immutable_prototype(prototype);
} }

View file

@ -141,7 +141,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::replace)
JS::ThrowCompletionOr<bool> LocationObject::internal_set_prototype_of(Object* prototype) JS::ThrowCompletionOr<bool> LocationObject::internal_set_prototype_of(Object* prototype)
{ {
// 1. Return ! SetImmutablePrototype(this, V). // 1. Return ! SetImmutablePrototype(this, V).
return set_immutable_prototype(prototype); return MUST(set_immutable_prototype(prototype));
} }
// https://html.spec.whatwg.org/multipage/history.html#location-isextensible // https://html.spec.whatwg.org/multipage/history.html#location-isextensible