From 25ae9851d87b71ca08e9460ecbf2ffead096911c Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Thu, 22 Sep 2022 00:49:00 -0700 Subject: [PATCH] [Temporal] Sync PR2377 order of observable in ...FromFields() Sync to the spec/calendar.html changes in https://github.com/tc39/proposal-temporal/pull/2377 to change the order of calling ToTemporalOverflow. This cl only cover the ISO8601 part, the the intl part of the PR is not yet implemented and will be handle when e implemenet them. Spec text: https://tc39.es/proposal-temporal/#sec-temporal-isodatefromfields https://tc39.es/proposal-temporal/#sec-temporal-isoyearmonthfromfields https://tc39.es/proposal-temporal/#sec-temporal-isomonthdayfromfields Bug: v8:11544 Change-Id: Ia4386d460dc45b0b377a483c6f4793da4cbd7c20 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3903223 Commit-Queue: Frank Tang Reviewed-by: Adam Klein Cr-Commit-Position: refs/heads/main@{#83410} --- src/objects/js-temporal-objects.cc | 37 +++++++++++++++--------------- test/test262/test262.status | 3 --- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/objects/js-temporal-objects.cc b/src/objects/js-temporal-objects.cc index 52dfd2f3cad8..e1a53e00d1b7 100644 --- a/src/objects/js-temporal-objects.cc +++ b/src/objects/js-temporal-objects.cc @@ -6381,19 +6381,18 @@ Maybe ISOMonthDayFromFields(Isolate* isolate, const char* method_name) { Factory* factory = isolate->factory(); // 1. Assert: Type(fields) is Object. - // 2. Let overflow be ? ToTemporalOverflow(options). - ShowOverflow overflow; - MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE( - isolate, overflow, ToTemporalOverflow(isolate, options, method_name), - Nothing()); - - // 3. Set fields to ? PrepareTemporalFields(fields, « "day", "month", + // 2. Set fields to ? PrepareTemporalFields(fields, « "day", "month", // "monthCode", "year" », «"day"»). Handle field_names = DayMonthMonthCodeYearInFixedArray(isolate); ASSIGN_RETURN_ON_EXCEPTION_VALUE( isolate, fields, PrepareTemporalFields(isolate, fields, field_names, RequiredFields::kDay), Nothing()); + // 3. Let overflow be ? ToTemporalOverflow(options). + ShowOverflow overflow; + MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE( + isolate, overflow, ToTemporalOverflow(isolate, options, method_name), + Nothing()); // 4. Let month be ! Get(fields, "month"). Handle month_obj = JSReceiver::GetProperty(isolate, fields, factory->month_string()) @@ -9705,12 +9704,7 @@ Maybe ISODateFromFields(Isolate* isolate, Handle fields, Factory* factory = isolate->factory(); // 1. Assert: Type(fields) is Object. - // 2. Let overflow be ? ToTemporalOverflow(options). - ShowOverflow overflow; - MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE( - isolate, overflow, ToTemporalOverflow(isolate, options, method_name), - Nothing()); - // 3. Set fields to ? PrepareTemporalFields(fields, « "day", "month", + // 2. Set fields to ? PrepareTemporalFields(fields, « "day", "month", // "monthCode", "year" », «"year", "day"»). Handle field_names = DayMonthMonthCodeYearInFixedArray(isolate); ASSIGN_RETURN_ON_EXCEPTION_VALUE( @@ -9718,6 +9712,11 @@ Maybe ISODateFromFields(Isolate* isolate, Handle fields, PrepareTemporalFields(isolate, fields, field_names, RequiredFields::kYearAndDay), Nothing()); + // 3. Let overflow be ? ToTemporalOverflow(options). + ShowOverflow overflow; + MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE( + isolate, overflow, ToTemporalOverflow(isolate, options, method_name), + Nothing()); // 4. Let year be ! Get(fields, "year"). Handle year_obj = @@ -9976,12 +9975,7 @@ Maybe ISOYearMonthFromFields(Isolate* isolate, const char* method_name) { Factory* factory = isolate->factory(); // 1. Assert: Type(fields) is Object. - // 2. Let overflow be ? ToTemporalOverflow(options). - ShowOverflow overflow; - MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE( - isolate, overflow, ToTemporalOverflow(isolate, options, method_name), - Nothing()); - // 3. Set fields to ? PrepareTemporalFields(fields, « "month", "monthCode", + // 2. Set fields to ? PrepareTemporalFields(fields, « "month", "monthCode", // "year" », «»). Handle field_names = factory->NewFixedArray(3); field_names->set(0, ReadOnlyRoots(isolate).month_string()); @@ -9992,6 +9986,11 @@ Maybe ISOYearMonthFromFields(Isolate* isolate, PrepareTemporalFields(isolate, fields, field_names, RequiredFields::kNone), Nothing()); + // 3. Let overflow be ? ToTemporalOverflow(options). + ShowOverflow overflow; + MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE( + isolate, overflow, ToTemporalOverflow(isolate, options, method_name), + Nothing()); // 4. Let year be ! Get(fields, "year"). Handle year_obj = diff --git a/test/test262/test262.status b/test/test262/test262.status index ebc70e0cf7c0..332b92c00c48 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -494,7 +494,6 @@ 'built-ins/Temporal/Calendar/from/calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/dateFromFields/order-of-operations': [FAIL], 'built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-case-insensitive': [FAIL], @@ -504,11 +503,9 @@ 'built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/monthDayFromFields/order-of-operations': [FAIL], 'built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/yearMonthFromFields/order-of-operations': [FAIL], 'built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Now/plainDate/calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Now/plainDateTime/calendar-case-insensitive': [FAIL],