From f54b1eb461b13635c3f63dd3c34271e0d45004ca Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Wed, 24 Aug 2022 23:36:18 -0700 Subject: [PATCH] [Temporal] Sync PR 2225 Consistently check overflow options https://github.com/tc39/proposal-temporal/pull/2225 Call ToTemporalOverflow in ToTemporalDate and ToTemporalDateTime Spec Text: https://tc39.es/proposal-temporal/#sec-temporal-totemporaldate https://tc39.es/proposal-temporal/#sec-temporal-totemporaldatetime Bug: v8:11544 Change-Id: I3d2846e2efc214ea5385be58cb49e319369b5900 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3855705 Reviewed-by: Shu-yu Guo Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/main@{#82797} --- src/objects/js-temporal-objects.cc | 34 +++++++++++++++++++++++------- test/test262/test262.status | 2 -- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/objects/js-temporal-objects.cc b/src/objects/js-temporal-objects.cc index 057f4a2754..336101baa3 100644 --- a/src/objects/js-temporal-objects.cc +++ b/src/objects/js-temporal-objects.cc @@ -2456,14 +2456,19 @@ MaybeHandle ToTemporalDate(Isolate* isolate, // b. If item has an [[InitializedTemporalZonedDateTime]] internal slot, // then if (item->IsJSTemporalZonedDateTime()) { - // i. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]). + // i. Perform ? ToTemporalOverflow(options). + MAYBE_RETURN_ON_EXCEPTION_VALUE( + isolate, ToTemporalOverflow(isolate, options, method_name), + Handle()); + + // ii. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]). Handle zoned_date_time = Handle::cast(item); Handle instant = temporal::CreateTemporalInstant( isolate, handle(zoned_date_time->nanoseconds(), isolate)) .ToHandleChecked(); - // ii. Let plainDateTime be ? + // iii. Let plainDateTime be ? // BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], // instant, item.[[Calendar]]). Handle plain_date_time; @@ -2475,7 +2480,7 @@ MaybeHandle ToTemporalDate(Isolate* isolate, instant, Handle(zoned_date_time->calendar(), isolate), method_name), JSTemporalPlainDate); - // iii. Return ! CreateTemporalDate(plainDateTime.[[ISOYear]], + // iv. Return ! CreateTemporalDate(plainDateTime.[[ISOYear]], // plainDateTime.[[ISOMonth]], plainDateTime.[[ISODay]], // plainDateTime.[[Calendar]]). return CreateTemporalDate( @@ -2489,7 +2494,11 @@ MaybeHandle ToTemporalDate(Isolate* isolate, // c. If item has an [[InitializedTemporalDateTime]] internal slot, then // item.[[ISODay]], item.[[Calendar]]). if (item->IsJSTemporalPlainDateTime()) { - // i. Return ! CreateTemporalDate(item.[[ISOYear]], item.[[ISOMonth]], + // i. Perform ? ToTemporalOverflow(options). + MAYBE_RETURN_ON_EXCEPTION_VALUE( + isolate, ToTemporalOverflow(isolate, options, method_name), + Handle()); + // ii. Return ! CreateTemporalDate(item.[[ISOYear]], item.[[ISOMonth]], Handle date_time = Handle::cast(item); return CreateTemporalDate(isolate, @@ -12313,14 +12322,18 @@ MaybeHandle ToTemporalDateTime( // b. If item has an [[InitializedTemporalZonedDateTime]] internal slot, // then if (item->IsJSTemporalZonedDateTime()) { - // i. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]). + // i. Perform ? ToTemporalOverflow(options). + MAYBE_RETURN_ON_EXCEPTION_VALUE( + isolate, ToTemporalOverflow(isolate, options, method_name), + Handle()); + // ii. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]). Handle zoned_date_time = Handle::cast(item); Handle instant = temporal::CreateTemporalInstant( isolate, handle(zoned_date_time->nanoseconds(), isolate)) .ToHandleChecked(); - // ii. Return ? + // iii. Return ? // temporal::BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], // instant, item.[[Calendar]]). return temporal::BuiltinTimeZoneGetPlainDateTimeFor( @@ -12329,8 +12342,13 @@ MaybeHandle ToTemporalDateTime( } // c. If item has an [[InitializedTemporalDate]] internal slot, then if (item->IsJSTemporalPlainDate()) { - // i. Return ? CreateTemporalDateTime(item.[[ISOYear]], item.[[ISOMonth]], - // item.[[ISODay]], 0, 0, 0, 0, 0, 0, item.[[Calendar]]). + // i. Perform ? ToTemporalOverflow(options). + MAYBE_RETURN_ON_EXCEPTION_VALUE( + isolate, ToTemporalOverflow(isolate, options, method_name), + Handle()); + // ii. Return ? CreateTemporalDateTime(item.[[ISOYear]], + // item.[[ISOMonth]], item.[[ISODay]], 0, 0, 0, 0, 0, 0, + // item.[[Calendar]]). Handle date = Handle::cast(item); return temporal::CreateTemporalDateTime( diff --git a/test/test262/test262.status b/test/test262/test262.status index 53e8013c93..5b02e27ddf 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -610,7 +610,6 @@ 'built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-datefromfields-called-with-null-prototype-fields': [FAIL], 'built-ins/Temporal/PlainDate/compare/argument-calendar-datefromfields-called-with-null-prototype-fields': [FAIL], 'built-ins/Temporal/PlainDate/from/argument-calendar-datefromfields-called-with-null-prototype-fields': [FAIL], - 'built-ins/Temporal/PlainDate/from/overflow-invalid-string': [FAIL], 'built-ins/Temporal/PlainDate/prototype/equals/argument-calendar-datefromfields-called-with-null-prototype-fields': [FAIL], 'built-ins/Temporal/PlainDate/prototype/since/argument-calendar-datefromfields-called-with-null-prototype-fields': [FAIL], 'built-ins/Temporal/PlainDate/prototype/since/calendar-dateuntil-called-with-null-prototype-options': [FAIL], @@ -622,7 +621,6 @@ 'built-ins/Temporal/PlainDate/prototype/with/calendar-mergefields-called-with-null-prototype-fields': [FAIL], 'built-ins/Temporal/PlainDateTime/compare/calendar-datefromfields-called-with-null-prototype-fields': [FAIL], 'built-ins/Temporal/PlainDateTime/from/calendar-datefromfields-called-with-null-prototype-fields': [FAIL], - 'built-ins/Temporal/PlainDateTime/from/overflow-invalid-string': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/since/calendar-datefromfields-called-with-null-prototype-fields': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-null-prototype-options': [FAIL],