diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-29 18:58:03 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-29 23:49:53 +0100 |
commit | ee8380edeabf822cf194eacaf081b801deea6c3a (patch) | |
tree | c9279b619cceb68ddcc02df32a2daef679762df7 /Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp | |
parent | fbfb0bb908fe74643ce4eddc72c2fb4cc7e6c68d (diff) | |
download | serenity-ee8380edeabf822cf194eacaf081b801deea6c3a.zip |
LibJS: Convert internal_own_property_keys() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 9e5e6061c8..ca844404e1 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -97,9 +97,7 @@ static Array* get_own_property_keys(GlobalObject& global_object, Value value, Ge return {}; // 2. Let keys be ? obj.[[OwnPropertyKeys]](). - auto keys = object->internal_own_property_keys(); - if (vm.exception()) - return {}; + auto keys = TRY_OR_DISCARD(object->internal_own_property_keys()); // 3. Let nameList be a new empty List. auto name_list = MarkedValueList { vm.heap() }; @@ -302,12 +300,13 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptors) auto* object = vm.argument(0).to_object(global_object); if (vm.exception()) return {}; + // 2. Let ownKeys be ? obj.[[OwnPropertyKeys]](). - auto own_keys = object->internal_own_property_keys(); - if (vm.exception()) - return {}; + auto own_keys = TRY_OR_DISCARD(object->internal_own_property_keys()); + // 3. Let descriptors be ! OrdinaryObjectCreate(%Object.prototype%). auto* descriptors = Object::create(global_object, global_object.object_prototype()); + // 4. For each element key of ownKeys, do for (auto& key : own_keys) { auto property_name = PropertyName::from_value(global_object, key); @@ -471,9 +470,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::assign) VERIFY(!vm.exception()); // ii. Let keys be ? from.[[OwnPropertyKeys]](). - auto keys = from->internal_own_property_keys(); - if (vm.exception()) - return {}; + auto keys = TRY_OR_DISCARD(from->internal_own_property_keys()); // iii. For each element nextKey of keys, do for (auto& next_key : keys) { |