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

LibJS: Convert to_integer_throw_on_infinity() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-09-15 23:03:38 +01:00
parent fea27143e9
commit 683e31e1ff
10 changed files with 46 additions and 125 deletions

View file

@ -62,14 +62,10 @@ Value PlainMonthDayConstructor::construct(FunctionObject& new_target)
}
// 3. Let m be ? ToIntegerThrowOnInfinity(isoMonth).
auto m = to_integer_throw_on_infinity(global_object, iso_month, ErrorType::TemporalInvalidPlainMonthDay);
if (vm.exception())
return {};
auto m = TRY_OR_DISCARD(to_integer_throw_on_infinity(global_object, iso_month, ErrorType::TemporalInvalidPlainMonthDay));
// 4. Let d be ? ToIntegerThrowOnInfinity(isoDay).
auto d = to_integer_throw_on_infinity(global_object, iso_day, ErrorType::TemporalInvalidPlainMonthDay);
if (vm.exception())
return {};
auto d = TRY_OR_DISCARD(to_integer_throw_on_infinity(global_object, iso_day, ErrorType::TemporalInvalidPlainMonthDay));
// 5. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
auto* calendar = to_temporal_calendar_with_iso_default(global_object, calendar_like);
@ -77,9 +73,7 @@ Value PlainMonthDayConstructor::construct(FunctionObject& new_target)
return {};
// 6. Let ref be ? ToIntegerThrowOnInfinity(referenceISOYear).
auto ref = to_integer_throw_on_infinity(global_object, reference_iso_year, ErrorType::TemporalInvalidPlainMonthDay);
if (vm.exception())
return {};
auto ref = TRY_OR_DISCARD(to_integer_throw_on_infinity(global_object, reference_iso_year, ErrorType::TemporalInvalidPlainMonthDay));
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behavior as the call to CreateTemporalMonthDay will immediately check that these values are valid