diff --git a/src/objects/js-temporal-objects.cc b/src/objects/js-temporal-objects.cc index 814ded00b6..367c079cff 100644 --- a/src/objects/js-temporal-objects.cc +++ b/src/objects/js-temporal-objects.cc @@ -2118,6 +2118,12 @@ MaybeHandle YearMonthFromFields( isolate->factory()->yearMonthFromFields_string(), JS_TEMPORAL_PLAIN_YEAR_MONTH_TYPE); } +MaybeHandle YearMonthFromFields( + Isolate* isolate, Handle calendar, Handle fields) { + // 1. If options is not present, set options to undefined. + return YearMonthFromFields(isolate, calendar, fields, + isolate->factory()->undefined_value()); +} // #sec-temporal-monthdayfromfields MaybeHandle MonthDayFromFields( @@ -2128,6 +2134,12 @@ MaybeHandle MonthDayFromFields( isolate->factory()->monthDayFromFields_string(), JS_TEMPORAL_PLAIN_MONTH_DAY_TYPE); } +MaybeHandle MonthDayFromFields( + Isolate* isolate, Handle calendar, Handle fields) { + // 1. If options is not present, set options to undefined. + return MonthDayFromFields(isolate, calendar, fields, + isolate->factory()->undefined_value()); +} // #sec-temporal-totemporaloverflow Maybe ToTemporalOverflow(Isolate* isolate, Handle options, @@ -13405,31 +13417,31 @@ MaybeHandle ToTemporalMonthDay( // j. Return ? MonthDayFromFields(calendar, fields, options). return MonthDayFromFields(isolate, calendar, fields, options); } - // 4. Perform ? ToTemporalOverflow(options). + // 5. Perform ? ToTemporalOverflow(options). MAYBE_RETURN_ON_EXCEPTION_VALUE( isolate, ToTemporalOverflow(isolate, options, method_name), Handle()); - // 5. Let string be ? ToString(item). + // 6. Let string be ? ToString(item). Handle string; ASSIGN_RETURN_ON_EXCEPTION(isolate, string, Object::ToString(isolate, item_obj), JSTemporalPlainMonthDay); - // 6. Let result be ? ParseTemporalMonthDayString(string). + // 7. Let result be ? ParseTemporalMonthDayString(string). DateRecord result; MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE( isolate, result, ParseTemporalMonthDayString(isolate, string), Handle()); - // 7. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]). + // 8. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]). Handle calendar; ASSIGN_RETURN_ON_EXCEPTION( isolate, calendar, ToTemporalCalendarWithISODefault(isolate, result.calendar, method_name), JSTemporalPlainMonthDay); - // 8. If result.[[Year]] is undefined, then + // 9. If result.[[Year]] is undefined, then // We use kMintInt31 to represent undefined if (result.date.year == kMinInt31) { // a. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], @@ -13439,21 +13451,18 @@ MaybeHandle ToTemporalMonthDay( } Handle created_result; - // 9. Set result to ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], - // calendar, referenceISOYear). + // 10. Set result to ? CreateTemporalMonthDay(result.[[Month]], + // result.[[Day]], calendar, referenceISOYear). ASSIGN_RETURN_ON_EXCEPTION( isolate, created_result, CreateTemporalMonthDay(isolate, result.date.month, result.date.day, calendar, kReferenceIsoYear), JSTemporalPlainMonthDay); - // 10. Let canonicalMonthDayOptions be ! OrdinaryObjectCreate(null). - Handle canonical_month_day_options = - factory->NewJSObjectWithNullProto(); - - // 11. Return ? MonthDayFromFields(calendar, result, - // canonicalMonthDayOptions). - return MonthDayFromFields(isolate, calendar, created_result, - canonical_month_day_options); + // 11. NOTE: The following operation is called without options, in order for + // the calendar to store a canonical value in the [[ISOYear]] internal slot of + // the result. + // 12. Return ? CalendarMonthDayFromFields(calendar, result). + return MonthDayFromFields(isolate, calendar, created_result); } MaybeHandle ToTemporalMonthDay( @@ -13796,7 +13805,6 @@ MaybeHandle ToTemporalYearMonth( const char* method_name) { TEMPORAL_ENTER_FUNC(); - Factory* factory = isolate->factory(); // 2. Assert: Type(options) is Object or Undefined. DCHECK(options->IsJSReceiver() || options->IsUndefined()); // 3. If Type(item) is Object, then @@ -13857,13 +13865,11 @@ MaybeHandle ToTemporalYearMonth( CreateTemporalYearMonth(isolate, result.date.year, result.date.month, calendar, result.date.day), JSTemporalPlainYearMonth); - // 9. Let canonicalYearMonthOptions be ! OrdinaryObjectCreate(null). - Handle canonical_year_month_options = - factory->NewJSObjectWithNullProto(); - // 10. Return ? YearMonthFromFields(calendar, result, - // canonicalYearMonthOptions). - return YearMonthFromFields(isolate, calendar, created_result, - canonical_year_month_options); + // 9. NOTE: The following operation is called without options, in order for + // the calendar to store a canonical value in the [[ISODay]] internal slot of + // the result. + // 10. Return ? CalendarYearMonthFromFields(calendar, result). + return YearMonthFromFields(isolate, calendar, created_result); } MaybeHandle ToTemporalYearMonth( diff --git a/test/test262/test262.status b/test/test262/test262.status index 8f6dbc7f54..0604736e7c 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -488,21 +488,14 @@ 'built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-negative-epochnanoseconds': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/balance': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/balance-negative-duration': [FAIL], - 'built-ins/Temporal/PlainMonthDay/from/calendar-monthdayfromfields-called-with-options-undefined': [FAIL], - 'built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-monthdayfromfields-called-with-options-undefined': [FAIL], 'built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/limits': [FAIL], 'built-ins/Temporal/PlainTime/prototype/add/argument-string-negative-fractional-units': [FAIL], 'built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets': [FAIL], - 'built-ins/Temporal/PlainYearMonth/compare/calendar-yearmonthfromfields-called-with-options-undefined': [FAIL], - 'built-ins/Temporal/PlainYearMonth/from/calendar-yearmonthfromfields-called-with-options-undefined': [FAIL], 'built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments': [FAIL], 'built-ins/Temporal/PlainYearMonth/prototype/add/overflow-wrong-type': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-yearmonthfromfields-called-with-options-undefined': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/since/calendar-yearmonthfromfields-called-with-options-undefined': [FAIL], 'built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments': [FAIL], 'built-ins/Temporal/PlainYearMonth/prototype/subtract/overflow-wrong-type': [FAIL], 'built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/limits': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/until/calendar-yearmonthfromfields-called-with-options-undefined': [FAIL], 'built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets': [FAIL], 'built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string': [FAIL], 'built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets': [FAIL],