1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

LibJS: Convert to_number() to ThrowCompletionOr

This commit is contained in:
Idan Horowitz 2021-10-17 23:20:05 +03:00
parent a36ee213b9
commit 20d990563c
22 changed files with 149 additions and 343 deletions

View file

@ -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");