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

LibJS: Convert to_property_descriptor() to ThrowCompletionOr

Also add spec step comments to it while we're here.
This commit is contained in:
Linus Groh 2021-10-03 20:07:00 +01:00
parent 2f42675ebd
commit d7d73f9100
6 changed files with 85 additions and 46 deletions

View file

@ -677,7 +677,6 @@ ThrowCompletionOr<bool> Object::internal_set(PropertyName const& property_name,
{
VERIFY(!value.is_empty());
VERIFY(!receiver.is_empty());
auto& vm = this->vm();
// 1. Assert: IsPropertyKey(P) is true.
VERIFY(property_name.is_valid());
@ -1069,9 +1068,7 @@ ThrowCompletionOr<Object*> Object::define_properties(Value properties)
auto descriptor_object = TRY(props->get(property_name));
// ii. Let desc be ? ToPropertyDescriptor(descObj).
auto descriptor = to_property_descriptor(global_object, descriptor_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
auto descriptor = TRY(to_property_descriptor(global_object, descriptor_object));
// iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
descriptors.append({ property_name, descriptor });