summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-09-15 20:55:07 +0100
committerLinus Groh <mail@linusgroh.de>2021-09-15 23:46:53 +0100
commitc4c40f4cf3cc1c98682c248f68b7233be4f1edc2 (patch)
tree5fea9074891aae655ab32bee7c2f77942983970a /Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
parent568296d0cc9016c8eefa7dd83ace616514ce261a (diff)
downloadserenity-c4c40f4cf3cc1c98682c248f68b7233be4f1edc2.zip
LibJS: Use ThrowCompletionOr in create_list_from_array_like()
Also add spec step comments to it while we're here.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ProxyObject.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ProxyObject.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
index 3637b07f50..39d99f6017 100644
--- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
@@ -817,16 +817,19 @@ MarkedValueList ProxyObject::internal_own_property_keys() const
// 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, ยซ String, Symbol ยป).
HashTable<StringOrSymbol> unique_keys;
- auto trap_result = create_list_from_array_like(global_object, trap_result_array, [&](auto value) {
+ auto throw_completion_or_trap_result = create_list_from_array_like(global_object, trap_result_array, [&](auto value) -> ThrowCompletionOr<void> {
auto& vm = global_object.vm();
- if (!value.is_string() && !value.is_symbol()) {
- vm.throw_exception<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysNotStringOrSymbol);
- return;
- }
+ if (!value.is_string() && !value.is_symbol())
+ return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysNotStringOrSymbol);
auto property_key = value.to_property_key(global_object);
VERIFY(!vm.exception());
unique_keys.set(property_key, AK::HashSetExistingEntryBehavior::Keep);
+ return {};
});
+ // TODO: This becomes a lot nicer once this function returns a ThrowCompletionOr as well.
+ if (throw_completion_or_trap_result.is_throw_completion())
+ return MarkedValueList { heap() };
+ auto trap_result = throw_completion_or_trap_result.release_value();
// 9. If trapResult contains any duplicate entries, throw a TypeError exception.
if (unique_keys.size() != trap_result.size()) {