mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:07:44 +00:00
LibJS: Convert reject_temporal_calendar_type() to ThrowCompletionOr
This commit is contained in:
parent
8dd45a1ba2
commit
8792fdfdf6
3 changed files with 6 additions and 6 deletions
|
@ -563,7 +563,7 @@ Optional<u16> maximum_temporal_duration_rounding_increment(StringView unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 13.26 RejectTemporalCalendarType ( object ), https://tc39.es/proposal-temporal/#sec-temporal-rejecttemporalcalendartype
|
// 13.26 RejectTemporalCalendarType ( object ), https://tc39.es/proposal-temporal/#sec-temporal-rejecttemporalcalendartype
|
||||||
void reject_temporal_calendar_type(GlobalObject& global_object, Object& object)
|
ThrowCompletionOr<void> reject_temporal_calendar_type(GlobalObject& global_object, Object& object)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
|
@ -572,8 +572,10 @@ void reject_temporal_calendar_type(GlobalObject& global_object, Object& object)
|
||||||
// 2. If object has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalTime]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
// 2. If object has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalTime]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
if (is<PlainDate>(object) || is<PlainDateTime>(object) || is<PlainMonthDay>(object) || is<PlainTime>(object) || is<PlainYearMonth>(object) || is<ZonedDateTime>(object)) {
|
if (is<PlainDate>(object) || is<PlainDateTime>(object) || is<PlainMonthDay>(object) || is<PlainTime>(object) || is<PlainYearMonth>(object) || is<ZonedDateTime>(object)) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
vm.throw_exception<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "calendar or timeZone");
|
return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "calendar or timeZone");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 13.27 FormatSecondsStringPart ( second, millisecond, microsecond, nanosecond, precision ), https://tc39.es/proposal-temporal/#sec-temporal-formatsecondsstringpart
|
// 13.27 FormatSecondsStringPart ( second, millisecond, microsecond, nanosecond, precision ), https://tc39.es/proposal-temporal/#sec-temporal-formatsecondsstringpart
|
||||||
|
|
|
@ -99,7 +99,7 @@ ThrowCompletionOr<Optional<String>> to_smallest_temporal_unit(GlobalObject&, Obj
|
||||||
ThrowCompletionOr<void> validate_temporal_unit_range(GlobalObject&, StringView largest_unit, StringView smallest_unit);
|
ThrowCompletionOr<void> validate_temporal_unit_range(GlobalObject&, StringView largest_unit, StringView smallest_unit);
|
||||||
String larger_of_two_temporal_units(StringView, StringView);
|
String larger_of_two_temporal_units(StringView, StringView);
|
||||||
Optional<u16> maximum_temporal_duration_rounding_increment(StringView unit);
|
Optional<u16> maximum_temporal_duration_rounding_increment(StringView unit);
|
||||||
void reject_temporal_calendar_type(GlobalObject&, Object&);
|
ThrowCompletionOr<void> reject_temporal_calendar_type(GlobalObject&, Object&);
|
||||||
String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision);
|
String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision);
|
||||||
double constrain_to_range(double x, double minimum, double maximum);
|
double constrain_to_range(double x, double minimum, double maximum);
|
||||||
BigInt* round_number_to_increment(GlobalObject&, BigInt const&, u64 increment, StringView rounding_mode);
|
BigInt* round_number_to_increment(GlobalObject&, BigInt const&, u64 increment, StringView rounding_mode);
|
||||||
|
|
|
@ -160,9 +160,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with)
|
||||||
auto& temporal_time_like = temporal_time_like_argument.as_object();
|
auto& temporal_time_like = temporal_time_like_argument.as_object();
|
||||||
|
|
||||||
// 4. Perform ? RejectTemporalCalendarType(temporalTimeLike).
|
// 4. Perform ? RejectTemporalCalendarType(temporalTimeLike).
|
||||||
reject_temporal_calendar_type(global_object, temporal_time_like);
|
TRY_OR_DISCARD(reject_temporal_calendar_type(global_object, temporal_time_like));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 5. Let calendarProperty be ? Get(temporalTimeLike, "calendar").
|
// 5. Let calendarProperty be ? Get(temporalTimeLike, "calendar").
|
||||||
auto calendar_property = temporal_time_like.get(vm.names.calendar);
|
auto calendar_property = temporal_time_like.get(vm.names.calendar);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue