LibJS: Reject ambiguous annotated time strings

This missing rejection will be caught by an upcoming Temporal.PlainTime
test.
This commit is contained in:
Timothy Flynn 2024-11-23 10:11:55 -05:00 committed by Tim Flynn
commit 0b59971ef9
Notes: github-actions[bot] 2024-11-24 00:38:22 +00:00
2 changed files with 13 additions and 2 deletions

View file

@ -1017,7 +1017,9 @@ ThrowCompletionOr<ParsedISODateTime> parse_iso_date_time(VM& vm, StringView iso_
// 4. If goal is TemporalMonthDayString and parseResult does not contain a DateYear Parse Node, then
if (goal == Production::TemporalMonthDayString && !parse_result->date_year.has_value()) {
// a. Assert: goal is the last element of allowedFormats.
VERIFY(goal == allowed_formats.last());
// FIXME: Spec issue: This assertion is possibly incorrect.
// https://github.com/tc39/proposal-temporal/issues/3045
// VERIFY(goal == allowed_formats.last());
// b. Set yearAbsent to true.
year_absent = true;

View file

@ -199,7 +199,16 @@ public:
// AnnotatedTime :::
// TimeDesignator Time DateTimeUTCOffset[~Z][opt] TimeZoneAnnotation[opt] Annotations[opt]
// Time DateTimeUTCOffset[~Z][opt] TimeZoneAnnotation[opt] Annotations[opt]
(void)parse_time_designator();
auto has_time_designator = parse_time_designator();
if (!has_time_designator) {
StateTransaction transaction { *this };
// It is a Syntax Error if ParseText(Time DateTimeUTCOffset[~Z], DateSpecMonthDay) is a Parse Node.
// It is a Syntax Error if ParseText(Time DateTimeUTCOffset[~Z], DateSpecYearMonth) is a Parse Node.
if (parse_date_spec_month_day() || parse_date_spec_year_month())
return false;
}
if (!parse_time())
return false;