diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-16 22:20:23 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-17 12:12:35 +0100 |
commit | c488f5a59d0bddfaa225b26e8ef7ab188f2ef4f2 (patch) | |
tree | 4b1cd6c54b6d9577af98faf4ea0a7696d2820a6e /Userland/Libraries/LibJS/Runtime/ReflectObject.cpp | |
parent | 1639ed7e0a9bc063599ec193b7b6af48f7d5faba (diff) | |
download | serenity-c488f5a59d0bddfaa225b26e8ef7ab188f2ef4f2.zip |
LibJS: Convert to_property_key() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ReflectObject.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ReflectObject.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index 6013a6ecbd..dec045be2f 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -112,9 +112,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property) } // 2. Let key be ? ToPropertyKey(propertyKey). - auto key = property_key.to_property_key(global_object); - if (vm.exception()) - return {}; + auto key = TRY_OR_DISCARD(property_key.to_property_key(global_object)); // 3. Let desc be ? ToPropertyDescriptor(attributes). auto descriptor = TRY_OR_DISCARD(to_property_descriptor(global_object, attributes)); @@ -136,9 +134,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::delete_property) } // 2. Let key be ? ToPropertyKey(propertyKey). - auto key = property_key.to_property_key(global_object); - if (vm.exception()) - return {}; + auto key = TRY_OR_DISCARD(property_key.to_property_key(global_object)); // 3. Return ? target.[[Delete]](key). return Value(TRY_OR_DISCARD(target.as_object().internal_delete(key))); @@ -158,9 +154,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get) } // 2. Let key be ? ToPropertyKey(propertyKey). - auto key = property_key.to_property_key(global_object); - if (vm.exception()) - return {}; + auto key = TRY_OR_DISCARD(property_key.to_property_key(global_object)); // 3. If receiver is not present, then if (vm.argument_count() < 3) { @@ -185,9 +179,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get_own_property_descriptor) } // 2. Let key be ? ToPropertyKey(propertyKey). - auto key = property_key.to_property_key(global_object); - if (vm.exception()) - return {}; + auto key = TRY_OR_DISCARD(property_key.to_property_key(global_object)); // 3. Let desc be ? target.[[GetOwnProperty]](key). auto descriptor = TRY_OR_DISCARD(target.as_object().internal_get_own_property(key)); @@ -224,9 +216,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::has) } // 2. Let key be ? ToPropertyKey(propertyKey). - auto key = property_key.to_property_key(global_object); - if (vm.exception()) - return {}; + auto key = TRY_OR_DISCARD(property_key.to_property_key(global_object)); // 3. Return ? target.[[HasProperty]](key). return Value(TRY_OR_DISCARD(target.as_object().internal_has_property(key))); @@ -295,9 +285,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::set) } // 2. Let key be ? ToPropertyKey(propertyKey). - auto key = property_key.to_property_key(global_object); - if (vm.exception()) - return {}; + auto key = TRY_OR_DISCARD(property_key.to_property_key(global_object)); // 3. If receiver is not present, then if (vm.argument_count() < 4) { |