Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyfill: Update per #2500 #2663

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions polyfill/lib/calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,6 @@ impl['iso8601'] = {
monthDayFromFields(fields, options, calendarSlotValue) {
fields = ES.PrepareTemporalFields(fields, ['day', 'month', 'monthCode', 'year'], ['day']);
const overflow = ES.ToTemporalOverflow(options);
if (fields.month !== undefined && fields.year === undefined && fields.monthCode === undefined) {
throw new TypeError('either year or monthCode required with month');
}
const referenceISOYear = 1972;
fields = resolveNonLunisolarMonth(fields);
let { month, day, year } = fields;
Expand Down Expand Up @@ -701,7 +698,7 @@ const nonIsoHelperBase = {
}
if (this.hasEra) {
if ((calendarDate['era'] === undefined) !== (calendarDate['eraYear'] === undefined)) {
throw new RangeError("properties 'era' and 'eraYear' must be provided together");
throw new TypeError("properties 'era' and 'eraYear' must be provided together");
}
}
},
Expand Down
13 changes: 4 additions & 9 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,24 +1345,16 @@ export function ToTemporalMonthDay(item, options) {
if (options !== undefined) options = SnapshotOwnProperties(GetOptionsObject(options), null);
if (Type(item) === 'Object') {
if (IsTemporalMonthDay(item)) return item;
let calendar, calendarAbsent;
let calendar;
if (HasSlot(item, CALENDAR)) {
calendar = GetSlot(item, CALENDAR);
calendarAbsent = false;
} else {
calendar = item.calendar;
calendarAbsent = calendar === undefined;
if (calendar === undefined) calendar = 'iso8601';
calendar = ToTemporalCalendarSlotValue(calendar);
}
const fieldNames = CalendarFields(calendar, ['day', 'month', 'monthCode', 'year']);
const fields = PrepareTemporalFields(item, fieldNames, []);
// Callers who omit the calendar are not writing calendar-independent
// code. In that case, `monthCode`/`year` can be omitted; `month` and
// `day` are sufficient. Add a `year` to satisfy calendar validation.
if (calendarAbsent && fields.month !== undefined && fields.monthCode === undefined && fields.year === undefined) {
fields.year = 1972;
}
return CalendarMonthDayFromFields(calendar, fields, options);
}

Expand All @@ -1373,6 +1365,9 @@ export function ToTemporalMonthDay(item, options) {
ToTemporalOverflow(options); // validate and ignore

if (referenceISOYear === undefined) {
if (calendar !== 'iso8601') {
throw new Error(`assertion failed: missing year with non-"iso8601" calendar identifier ${calendar}`);
}
RejectISODate(1972, month, day);
return CreateTemporalMonthDay(month, day, calendar);
}
Expand Down
2 changes: 1 addition & 1 deletion polyfill/test262
Submodule test262 updated 66 files
+9 −9 .circleci/config.yml
+1 −0 CODEOWNERS
+4 −17 features.txt
+20 −0 harness/temporalHelpers.js
+1 −1 src/decorator/syntax/class-valid/cls-decl-decorators-valid-syntax.template
+2 −2 src/decorator/syntax/class-valid/cls-expr-decorators-valid-syntax.template
+28 −0 test/built-ins/Object/prototype/toString/symbol-tag-array-builtin.js
+35 −0 test/built-ins/Object/prototype/toString/symbol-tag-generators-builtin.js
+33 −0 test/built-ins/Object/prototype/toString/symbol-tag-map-builtin.js
+1 −53 test/built-ins/Object/prototype/toString/symbol-tag-non-str-builtin.js
+23 −0 test/built-ins/Object/prototype/toString/symbol-tag-promise-builtin.js
+33 −0 test/built-ins/Object/prototype/toString/symbol-tag-set-builtin.js
+31 −0 test/built-ins/Object/prototype/toString/symbol-tag-string-builtin.js
+21 −0 test/built-ins/Object/prototype/toString/symbol-tag-weakmap-builtin.js
+21 −0 test/built-ins/Object/prototype/toString/symbol-tag-weakset-builtin.js
+25 −17 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/basic.js
+7 −3 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/fields-missing-properties.js
+12 −18 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js
+43 −69 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-constrain.js
+24 −26 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-reject.js
+0 −35 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/reference-year-1972.js
+513 −0 test/built-ins/Temporal/Duration/compare/exhaustive.js
+55 −0 ...ins/Temporal/Duration/compare/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+56 −0 ...mporal/Duration/prototype/add/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+21 −0 test/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js
+56 −0 ...oral/Duration/prototype/round/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+56 −0 ...l/Duration/prototype/subtract/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+21 −0 test/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js
+56 −0 ...oral/Duration/prototype/total/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+24 −0 test/built-ins/Temporal/Instant/compare/exhaustive.js
+68 −0 test/built-ins/Temporal/PlainDate/compare/exhaustive.js
+55 −0 ...ilt-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js
+164 −0 test/built-ins/Temporal/PlainDateTime/compare/exhaustive.js
+55 −0 ...ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js
+31 −0 test/built-ins/Temporal/PlainMonthDay/from/calendar-monthdayfromfields-validates-fields.js
+0 −1 test/built-ins/Temporal/PlainMonthDay/from/fields-missing-properties.js
+4 −0 test/built-ins/Temporal/PlainMonthDay/from/fields-object.js
+3 −2 test/built-ins/Temporal/PlainMonthDay/prototype/with/basic.js
+116 −0 test/built-ins/Temporal/PlainTime/compare/exhaustive.js
+55 −0 ...ilt-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js
+47 −0 test/built-ins/Temporal/PlainYearMonth/compare/exhaustive.js
+30 −0 test/built-ins/Temporal/PlainYearMonth/prototype/add/end-of-month-out-of-range.js
+30 −0 test/built-ins/Temporal/PlainYearMonth/prototype/subtract/end-of-month-out-of-range.js
+56 −0 .../built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-called-with-iso8601-calendar.js
+58 −0 .../Temporal/ZonedDateTime/compare/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+29 −0 test/built-ins/Temporal/ZonedDateTime/compare/exhaustive.js
+55 −0 ...ins/Temporal/ZonedDateTime/from/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+56 −0 .../ZonedDateTime/prototype/equals/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+55 −0 ...uilt-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-called-with-iso8601-calendar.js
+55 −0 test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-called-with-iso8601-calendar.js
+56 −0 ...l/ZonedDateTime/prototype/since/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+55 −0 ...uilt-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-called-with-iso8601-calendar.js
+56 −0 ...l/ZonedDateTime/prototype/until/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js
+58 −0 test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-called-with-iso8601-calendar.js
+55 −0 ...t-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-called-with-iso8601-calendar.js
+55 −0 ...t-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-called-with-iso8601-calendar.js
+3 −3 test/intl402/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js
+20 −0 test/intl402/Temporal/Calendar/prototype/monthDayFromFields/fields-underspecified.js
+0 −19 test/intl402/Temporal/Calendar/prototype/monthDayFromFields/one-of-era-erayear-undefined.js
+3 −3 test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js
+12 −0 test/intl402/Temporal/PlainMonthDay/from/fields-missing-properties.js
+33 −0 test/intl402/Temporal/PlainMonthDay/from/fields-object.js
+12 −0 test/intl402/Temporal/PlainMonthDay/prototype/with/fields-missing-properties.js
+2 −2 test/language/expressions/class/decorator/syntax/class-valid/decorator-member-expr-private-identifier.js
+1 −1 test/language/statements/class/decorator/syntax/class-valid/decorator-member-expr-private-identifier.js
+26 −19 tools/lint/lint.py
2 changes: 1 addition & 1 deletion spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ <h1>ISOMonthDayFromFields ( _fields_, _overflow_ )</h1>
1. Let _day_ be ! Get(_fields_, *"day"*).
1. Assert: _month_ and _day_ are Numbers.
1. Let _year_ be ! Get(_fields_, *"year"*).
1. Let _referenceISOYear_ be 1972 (the first leap year after the epoch).
1. Let _referenceISOYear_ be 1972 (the first ISO 8601 leap year after the epoch).
1. If _year_ is *undefined*, then
1. Let _result_ be ? RegulateISODate(_referenceISOYear_, ℝ(_month_), ℝ(_day_), _overflow_).
1. Else,
Expand Down
4 changes: 4 additions & 0 deletions spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -1855,13 +1855,17 @@ <h1>
<ul>
<li>If _type_ is ~date~ or ~month-day~ and *"day"* in the calendar has an interpretation analogous to ISO 8601 and its corresponding value is *undefined*.</li>
<li>If *"month"* and *"monthCode"* in the calendar have interpretations analogous to ISO 8601 and either the corresponding values for both are *undefined* or neither value is *undefined* but they do not identify the same month.</li>
<li>If _type_ is ~month-day~ and the value for *"monthCode"* is *undefined* and a year cannot be determined from _fields_.</li>
<li>If _type_ is ~date~ or ~year-month~ and the calendar supports the usual partitioning of years into eras with their own year counting as represented by *"year"*, *"era"*, and *"eraYear"* (as in the Gregorian or traditional Japanese calendars) and any of the following cases apply:<ul>
<li>The value for each of *"year"* and *"era"* and *"eraYear"* is *undefined*.</li>
<li>The value for *"era"* is *undefined* but the value for *"eraYear"* is not.</li>
<li>The value for *"eraYear"* is *undefined* but the value for *"era"* is not.</li>
<li>None of the three values are *undefined* but the values for *"era"* and *"eraYear"* do not together identify the same year as the value for *"year"*.</li>
</ul></li>
</ul>
<emu-note>
When _type_ is ~month-day~ and *"month"* is provided without *"monthCode"*, it is recommended that all built-in calendars other than the ISO 8601 calendar require a disambiguating year (e.g., either *"year"* or *"era"* and *"eraYear"*), including those that always use exactly the same months as the ISO 8601 calendar (which receives special handling in this specification as a default calendar that is permanently stable for automated processing).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know if we want this, but maybe:

Suggested change
When _type_ is ~month-day~ and *"month"* is provided without *"monthCode"*, it is recommended that all built-in calendars other than the ISO 8601 calendar require a disambiguating year (e.g., either *"year"* or *"era"* and *"eraYear"*), including those that always use exactly the same months as the ISO 8601 calendar (which receives special handling in this specification as a default calendar that is permanently stable for automated processing).
When _type_ is ~month-day~ and *"month"* is provided without *"monthCode"*, all built-in calendars other than the ISO 8601 calendar must require a disambiguating year (e.g., either *"year"* or *"era"* and *"eraYear"*), including those that always use exactly the same months as the ISO 8601 calendar (which receives special handling in this specification as a default calendar that is permanently stable for automated processing).

(in order to make it clear that there should not be implementation divergence)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely don't want to introduce such a strong statement in this PR, and I'm not sure it belongs in the text at all (it's true that built-in calendars are constrained to CLDR, but that source itself can change over time). Even CalendarDateMonthCode, which I consider to be much more strict regarding "M##[L]" formatting, uses "should" rather than "must".

</emu-note>
</emu-clause>
</emu-clause>

Expand Down
20 changes: 5 additions & 15 deletions spec/plainmonthday.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ <h1>Temporal.PlainMonthDay ( _isoMonth_, _isoDay_ [ , _calendarLike_ [ , _refere
1. If NewTarget is *undefined*, then
1. Throw a *TypeError* exception.
1. If _referenceISOYear_ is *undefined*, then
1. Set _referenceISOYear_ to *1972*<sub>𝔽</sub>.
1. Set _referenceISOYear_ to *1972*<sub>𝔽</sub> (the first ISO 8601 leap year after the epoch).
1. Let _m_ be ? ToIntegerWithTruncation(_isoMonth_).
1. Let _d_ be ? ToIntegerWithTruncation(_isoDay_).
1. Let _calendar_ be ? ToTemporalCalendarSlotValue(_calendarLike_, *"iso8601"*).
1. Let _ref_ be ? ToIntegerWithTruncation(_referenceISOYear_).
1. Return ? CreateTemporalMonthDay(_m_, _d_, _calendar_, _ref_, NewTarget).
1. Let _y_ be ? ToIntegerWithTruncation(_referenceISOYear_).
1. Return ? CreateTemporalMonthDay(_m_, _d_, _calendar_, _y_, NewTarget).
</emu-alg>
<emu-note>1972 is the first leap year after the epoch.</emu-note>
</emu-clause>
</emu-clause>

Expand Down Expand Up @@ -366,27 +365,16 @@ <h1>
<emu-alg>
1. If _options_ is not present, set _options_ to *undefined*.
1. If _options_ is not *undefined*, set _options_ to ? SnapshotOwnProperties(! GetOptionsObject(_options_), *null*).
1. Let _referenceISOYear_ be 1972 (the first leap year after the epoch).
1. If Type(_item_) is Object, then
1. If _item_ has an [[InitializedTemporalMonthDay]] internal slot, then
1. Return _item_.
1. If _item_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
1. Let _calendar_ be _item_.[[Calendar]].
1. Let _calendarAbsent_ be *false*.
1. Else,
1. Let _calendarLike_ be ? Get(_item_, *"calendar"*).
1. If _calendarLike_ is *undefined*, then
1. Let _calendarAbsent_ be *true*.
1. Else,
1. Let _calendarAbsent_ be *false*.
1. Let _calendar_ be ? ToTemporalCalendarSlotValue(_calendarLike_, *"iso8601"*).
1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »).
1. Let _fields_ be ? PrepareTemporalFields(_item_, _fieldNames_, «»).
1. Let _month_ be ! Get(_fields_, *"month"*).
1. Let _monthCode_ be ! Get(_fields_, *"monthCode"*).
1. Let _year_ be ! Get(_fields_, *"year"*).
1. If _calendarAbsent_ is *true*, and _month_ is not *undefined*, and _monthCode_ is *undefined* and _year_ is *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"year"*, 𝔽(_referenceISOYear_)).
1. Return ? CalendarMonthDayFromFields(_calendar_, _fields_, _options_).
1. If _item_ is not a String, throw a *TypeError* exception.
1. Let _result_ be ? ParseTemporalMonthDayString(_item_).
Expand All @@ -396,6 +384,8 @@ <h1>
1. Set _calendar_ to the ASCII-lowercase of _calendar_.
1. Perform ? ToTemporalOverflow(_options_).
1. If _result_.[[Year]] is *undefined*, then
1. Assert: _calendar_ is *"iso8601"*.
1. Let _referenceISOYear_ be 1972 (the first ISO 8601 leap year after the epoch).
1. Return ? CreateTemporalMonthDay(_result_.[[Month]], _result_.[[Day]], _calendar_, _referenceISOYear_).
1. Set _result_ to ? CreateTemporalMonthDay(_result_.[[Month]], _result_.[[Day]], _calendar_, _result_.[[Year]]).
1. 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.
Expand Down