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

Normative: Merge PrepareTemporalFields #2472

Merged
merged 5 commits into from
Mar 8, 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: 5 additions & 0 deletions polyfill/lib/calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ const nonIsoHelperBase = {
throw new RangeError(`eraYear ${eraYear} does not match year ${year}`);
}
}
if (this.hasEra) {
if ((calendarDate['era'] === undefined) !== (calendarDate['eraYear'] === undefined)) {
throw new RangeError("properties 'era' and 'eraYear' must be provided together");
}
}
},
/**
* Allows derived calendars to add additional fields and/or to make
Expand Down
3 changes: 0 additions & 3 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,9 +1029,6 @@ export const ES = ObjectAssign({}, ES2022, {
if (requiredFields === 'partial' && !any) {
throw new TypeError(emptySourceErrorMessage);
}
if ((result['era'] === undefined) !== (result['eraYear'] === undefined)) {
throw new RangeError("properties 'era' and 'eraYear' must be provided together");
}
return result;
},
ToTemporalTimeRecord: (bag, completeness = 'complete') => {
Expand Down
2 changes: 1 addition & 1 deletion polyfill/test262
Submodule test262 updated 26 files
+1 −1 harness/temporalHelpers.js
+35 −0 test/built-ins/Array/fromAsync/mapfn-async-arraylike.js
+35 −0 test/built-ins/Array/fromAsync/mapfn-async-iterable-async.js
+35 −0 test/built-ins/Array/fromAsync/mapfn-async-iterable-sync.js
+40 −0 test/built-ins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js
+40 −0 test/built-ins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js
+23 −0 test/built-ins/Array/fromAsync/mapfn-async-throws.js
+25 −0 test/built-ins/Array/fromAsync/mapfn-not-callable.js
+47 −0 test/built-ins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js
+35 −0 test/built-ins/Array/fromAsync/mapfn-sync-arraylike.js
+33 −0 test/built-ins/Array/fromAsync/mapfn-sync-iterable-async.js
+33 −0 test/built-ins/Array/fromAsync/mapfn-sync-iterable-sync.js
+39 −0 test/built-ins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js
+39 −0 test/built-ins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js
+22 −0 test/built-ins/Array/fromAsync/mapfn-sync-throws.js
+21 −0 test/built-ins/Array/fromAsync/thisarg-object.js
+33 −0 test/built-ins/Array/fromAsync/thisarg-omitted-sloppy.js
+28 −0 test/built-ins/Array/fromAsync/thisarg-omitted-strict.js
+75 −0 test/built-ins/Array/fromAsync/thisarg-primitive-sloppy.js
+49 −0 test/built-ins/Array/fromAsync/thisarg-primitive-strict.js
+16 −0 test/built-ins/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js
+16 −0 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/one-of-era-erayear-undefined.js
+16 −0 test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js
+19 −0 test/intl402/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js
+19 −0 test/intl402/Temporal/Calendar/prototype/monthDayFromFields/one-of-era-erayear-undefined.js
+19 −0 test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js
56 changes: 0 additions & 56 deletions spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2540,61 +2540,5 @@ <h1>get Temporal.ZonedDateTime.prototype.eraYear</h1>
</emu-clause>
</emu-clause>
</ins>

<ins class="block">
<emu-clause id="sec-abstracts">
<h1>Abstract Operations</h1>

<emu-clause id="sup-temporal-preparetemporalfields" type="abstract operation">
<h1>
PrepareTemporalFields (
_fields_: an Object,
_fieldNames_: a List of property names,
_requiredFields_: ~partial~ or a List of property names,
): either a normal completion containing an Object, or an abrupt completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>This definition supersedes the definition provided in <emu-xref href="#sec-temporal-preparetemporalfields"></emu-xref>.</dd>
<dt>redefinition</dt>
<dd>true</dd>
</dl>
<emu-alg>
1. Let _result_ be OrdinaryObjectCreate(*null*).
1. Let _any_ be *false*.
1. For each property name _property_ of _fieldNames_, do
1. Let _value_ be ? Get(_fields_, _property_).
1. If _value_ is not *undefined*, then
1. Set _any_ to *true*.
1. If _property_ is in the Property column of <emu-xref href="#table-temporal-field-requirements"></emu-xref> and there is a Conversion value in the same row, then
1. Let _Conversion_ be the Conversion value of the same row.
1. If _Conversion_ is ~ToIntegerWithTruncation~, then
1. Set _value_ to ? ToIntegerWithTruncation(_value_).
1. Set _value_ to 𝔽(_value_).
1. Else if _Conversion_ is ~ToPositiveIntegerWithTruncation~, then
1. Set _value_ to ? ToPositiveIntegerWithTruncation(_value_).
1. Set _value_ to 𝔽(_value_).
1. Else,
1. Assert: _Conversion_ is ~ToString~.
1. Set _value_ to ? ToString(_value_).
1. Perform ! CreateDataPropertyOrThrow(_result_, _property_, _value_).
1. Else if _requiredFields_ is a List, then
1. If _requiredFields_ contains _property_, then
1. Throw a *TypeError* exception.
1. If _property_ is in the Property column of <emu-xref href="#table-temporal-field-requirements"></emu-xref>, then
1. Set _value_ to the corresponding Default value of the same row.
1. Perform ! CreateDataPropertyOrThrow(_result_, _property_, _value_).
1. If _requiredFields_ is ~partial~ and _any_ is *false*, then
1. Throw a *TypeError* exception.
1. If _requiredFields_ is not ~partial~, then
1. Let _era_ be ? Get(_result_, *"era"*).
1. Let _eraYear_ be ? Get(_result_, *"eraYear"*).
1. If _era_ is *undefined* and _eraYear_ is not *undefined*, or if _era_ is not *undefined* and _eraYear_ is *undefined*, then
1. Throw a *RangeError* exception.
1. Return _result_.
</emu-alg>
</emu-clause>
</emu-clause>
</ins>
</emu-clause>
</emu-clause>