Skip to content

Commit

Permalink
[Temporal] Sync PR2377 order of observable in ...FromFields()
Browse files Browse the repository at this point in the history
Sync to the spec/calendar.html changes in
tc39/proposal-temporal#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 <[email protected]>
Reviewed-by: Adam Klein <[email protected]>
Cr-Commit-Position: refs/heads/main@{#83410}
  • Loading branch information
FrankYFTang authored and V8 LUCI CQ committed Sep 24, 2022
1 parent 97c0084 commit 25ae985
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
37 changes: 18 additions & 19 deletions src/objects/js-temporal-objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6381,19 +6381,18 @@ Maybe<DateRecord> 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<DateRecord>());

// 3. Set fields to ? PrepareTemporalFields(fields, « "day", "month",
// 2. Set fields to ? PrepareTemporalFields(fields, « "day", "month",
// "monthCode", "year" », «"day"»).
Handle<FixedArray> field_names = DayMonthMonthCodeYearInFixedArray(isolate);
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, fields,
PrepareTemporalFields(isolate, fields, field_names, RequiredFields::kDay),
Nothing<DateRecord>());
// 3. Let overflow be ? ToTemporalOverflow(options).
ShowOverflow overflow;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, overflow, ToTemporalOverflow(isolate, options, method_name),
Nothing<DateRecord>());
// 4. Let month be ! Get(fields, "month").
Handle<Object> month_obj =
JSReceiver::GetProperty(isolate, fields, factory->month_string())
Expand Down Expand Up @@ -9705,19 +9704,19 @@ Maybe<DateRecord> ISODateFromFields(Isolate* isolate, Handle<JSReceiver> 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<DateRecord>());
// 3. Set fields to ? PrepareTemporalFields(fields, « "day", "month",
// 2. Set fields to ? PrepareTemporalFields(fields, « "day", "month",
// "monthCode", "year" », «"year", "day"»).
Handle<FixedArray> field_names = DayMonthMonthCodeYearInFixedArray(isolate);
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, fields,
PrepareTemporalFields(isolate, fields, field_names,
RequiredFields::kYearAndDay),
Nothing<DateRecord>());
// 3. Let overflow be ? ToTemporalOverflow(options).
ShowOverflow overflow;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, overflow, ToTemporalOverflow(isolate, options, method_name),
Nothing<DateRecord>());

// 4. Let year be ! Get(fields, "year").
Handle<Object> year_obj =
Expand Down Expand Up @@ -9976,12 +9975,7 @@ Maybe<DateRecord> 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<DateRecord>());
// 3. Set fields to ? PrepareTemporalFields(fields, « "month", "monthCode",
// 2. Set fields to ? PrepareTemporalFields(fields, « "month", "monthCode",
// "year" », «»).
Handle<FixedArray> field_names = factory->NewFixedArray(3);
field_names->set(0, ReadOnlyRoots(isolate).month_string());
Expand All @@ -9992,6 +9986,11 @@ Maybe<DateRecord> ISOYearMonthFromFields(Isolate* isolate,
PrepareTemporalFields(isolate, fields, field_names,
RequiredFields::kNone),
Nothing<DateRecord>());
// 3. Let overflow be ? ToTemporalOverflow(options).
ShowOverflow overflow;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, overflow, ToTemporalOverflow(isolate, options, method_name),
Nothing<DateRecord>());

// 4. Let year be ! Get(fields, "year").
Handle<Object> year_obj =
Expand Down
3 changes: 0 additions & 3 deletions test/test262/test262.status
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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],
Expand Down

0 comments on commit 25ae985

Please sign in to comment.