1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +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

@ -651,9 +651,7 @@ ThrowCompletionOr<Optional<int>> default_number_option(GlobalObject& global_obje
return fallback;
// 2. Let value be ? ToNumber(value).
value = value.to_number(global_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
value = TRY(value.to_number(global_object));
// 3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
if (value.is_nan() || (value.as_double() < minimum) || (value.as_double() > maximum))