summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Array.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-10-17 23:20:05 +0300
committerIdan Horowitz <idan.horowitz@gmail.com>2021-10-18 08:01:38 +0300
commit20d990563cf858d51d4c6bf93a7c37317c5ecd12 (patch)
tree4833bfedf796eec4a2b6da5bc2ac546a0ab6177f /Userland/Libraries/LibJS/Runtime/Array.cpp
parenta36ee213b99113b4edb2f6f1578ab21582a0adfa (diff)
downloadserenity-20d990563cf858d51d4c6bf93a7c37317c5ecd12.zip
LibJS: Convert to_number() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Array.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Array.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp
index d26971a632..3d34bcbb23 100644
--- a/Userland/Libraries/LibJS/Runtime/Array.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Array.cpp
@@ -76,9 +76,7 @@ bool Array::set_length(PropertyDescriptor const& property_descriptor)
if (vm.exception())
return {};
// 4. Let numberLen be ? ToNumber(Desc.[[Value]]).
- auto number_length = property_descriptor.value->to_number(global_object);
- if (vm.exception())
- return {};
+ auto number_length = TRY_OR_DISCARD(property_descriptor.value->to_number(global_object));
// 5. If newLen is not the same value as numberLen, throw a RangeError exception.
if (new_length != number_length.as_double()) {
vm.throw_exception<RangeError>(global_object, ErrorType::InvalidLength, "array");