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

LibJS: Use the new force_throw_exception in delete_property

This commit is contained in:
davidot 2021-06-21 16:07:56 +02:00 committed by Linus Groh
parent 16b87b85e3
commit e10219a293

View file

@ -298,7 +298,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::unshift)
if (vm.exception()) if (vm.exception())
return {}; return {};
} else { } else {
this_object->delete_property(to); this_object->delete_property(to, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
} }
@ -340,7 +340,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::pop)
auto element = this_object->get(index).value_or(js_undefined()); auto element = this_object->get(index).value_or(js_undefined());
if (vm.exception()) if (vm.exception())
return {}; return {};
this_object->delete_property(index); this_object->delete_property(index, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
this_object->put(vm.names.length, Value((i32)index)); this_object->put(vm.names.length, Value((i32)index));
@ -382,13 +382,13 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::shift)
if (vm.exception()) if (vm.exception())
return {}; return {};
} else { } else {
this_object->delete_property(to); this_object->delete_property(to, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
} }
} }
this_object->delete_property(length - 1); this_object->delete_property(length - 1, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
@ -848,11 +848,11 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reverse)
this_object->put(lower, upper_value); this_object->put(lower, upper_value);
if (vm.exception()) if (vm.exception())
return {}; return {};
this_object->delete_property(upper); this_object->delete_property(upper, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
} else if (lower_exists && !upper_exists) { } else if (lower_exists && !upper_exists) {
this_object->delete_property(lower); this_object->delete_property(lower, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
this_object->put(upper, lower_value); this_object->put(upper, lower_value);
@ -1018,7 +1018,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::sort)
// compare function. FIXME: For performance, a similar process could be used // compare function. FIXME: For performance, a similar process could be used
// for undefined, which are sorted to right before the empty values. // for undefined, which are sorted to right before the empty values.
for (size_t i = values_to_sort.size(); i < original_length; ++i) { for (size_t i = values_to_sort.size(); i < original_length; ++i) {
array->delete_property(i); array->delete_property(i, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
} }
@ -1229,14 +1229,14 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice)
if (!from.is_empty()) { if (!from.is_empty()) {
this_object->put(to, from); this_object->put(to, from);
} else { } else {
this_object->delete_property(to); this_object->delete_property(to, true);
} }
if (vm.exception()) if (vm.exception())
return {}; return {};
} }
for (size_t i = initial_length; i > new_length; --i) { for (size_t i = initial_length; i > new_length; --i) {
this_object->delete_property(i - 1); this_object->delete_property(i - 1, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
} }
@ -1251,7 +1251,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice)
if (!from.is_empty()) { if (!from.is_empty()) {
this_object->put(to, from); this_object->put(to, from);
} else { } else {
this_object->delete_property(to); this_object->delete_property(to, true);
} }
if (vm.exception()) if (vm.exception())
return {}; return {};
@ -1523,7 +1523,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::copy_within)
if (vm.exception()) if (vm.exception())
return {}; return {};
} else { } else {
this_object->delete_property(to_i); this_object->delete_property(to_i, true);
if (vm.exception()) if (vm.exception())
return {}; return {};
} }