Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Rest of AggregateError spec #37

Merged
merged 32 commits into from
Oct 1, 2019
Merged
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5e0c185
Rest of AggregateError spec
chicoxyzzy Sep 25, 2019
df78799
Remove unnecessary list item
chicoxyzzy Sep 25, 2019
79d9bf8
Add `The _AggregateError_ Constructors` part
chicoxyzzy Sep 25, 2019
6389a45
constructor - constructors
chicoxyzzy Sep 25, 2019
165c5a1
each -> the
chicoxyzzy Sep 25, 2019
8811f9e
construtor -> constructors
chicoxyzzy Sep 25, 2019
e8632b2
each -> the
chicoxyzzy Sep 25, 2019
f42c80e
remove unnecessary text
chicoxyzzy Sep 25, 2019
07624af
objects -> object
chicoxyzzy Sep 25, 2019
51f3dfc
each -> the
chicoxyzzy Sep 25, 2019
b2e5483
Rephrase AggregateError prototype properties description
chicoxyzzy Sep 25, 2019
d66f4d8
add mention of NativeError to Properties of AggregateError Instances …
chicoxyzzy Sep 25, 2019
235da75
Update AggragateError and NativeError
chicoxyzzy Sep 25, 2019
12f2e1a
Update link to AggregateError Object Structure section
chicoxyzzy Sep 25, 2019
0c9ca6d
Revert AggregateError function semantics to master branch
chicoxyzzy Sep 25, 2019
651fbfb
Update AggregateError prototype
chicoxyzzy Sep 25, 2019
430cf09
Fix AggregateError.prototype.name initial value
chicoxyzzy Sep 25, 2019
57c2e1d
fix spelling
chicoxyzzy Sep 25, 2019
a4e1b61
Remove obsolete AggregateError Object Structure description
chicoxyzzy Sep 25, 2019
d396a83
fix AggregateError.prototype.name description
chicoxyzzy Sep 25, 2019
a2eb792
Update AggregateError.prototype.errors description
chicoxyzzy Sep 25, 2019
1d16f24
Update AggregateError.prototype.name description
chicoxyzzy Sep 25, 2019
f5431d2
use %AggregateErrorPrototype% intrinsic
chicoxyzzy Sep 25, 2019
c3e8e2e
fix AggregateError.prototype description
chicoxyzzy Sep 25, 2019
44b1c52
Add AggregateError.prototype.toString method
chicoxyzzy Sep 26, 2019
8b9064c
Update Native Error Types Used in This Standard prose
chicoxyzzy Sep 26, 2019
d628750
Update spec.html
chicoxyzzy Sep 26, 2019
43ffa4c
Remove unnecessary var tag
chicoxyzzy Sep 26, 2019
2fa9b4d
Merge branch 'rest-of-aggregateerror' of github.com:chicoxyzzy/propos…
chicoxyzzy Sep 26, 2019
a617313
AggregateError.prototype.toString() fixes
chicoxyzzy Sep 30, 2019
8ad81ad
Fix name in AggregateError.prototype.toString()
chicoxyzzy Sep 30, 2019
2474cfd
Remove number of errors from AggregateError.prototype.toString()
chicoxyzzy Sep 30, 2019
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
192 changes: 145 additions & 47 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,151 @@ <h1>Introduction</h1>
<p>`Promise.any()` accepts an array of promises and returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an array of rejection reasons if all of the given promises are rejected.</p>
</emu-intro>

<emu-clause id="sec-well-known-intrinsic-objects">
<h1>Well-Known Intrinsic Objects</h1>
<p>Well-known intrinsics are built-in objects that are explicitly referenced by the algorithms of this specification and which usually have realm-specific identities. Unless otherwise specified each intrinsic object actually corresponds to a set of similar objects, one per realm.</p>
<p>Within this specification a reference such as %name% means the intrinsic object, associated with the current realm, corresponding to the name. Determination of the current realm and its intrinsics is described in <emu-xref href="#sec-execution-contexts"></emu-xref>. The well-known intrinsics are listed in <emu-xref href="#table-7"></emu-xref>.</p>
<emu-table id="table-7" caption="Well-Known Intrinsic Objects">
<table>
<tbody>
<tr>
<th>
Intrinsic Name
</th>
<th>
Global Name
</th>
<th>
ECMAScript Language Association
</th>
</tr>
<tr>
<td>
<ins>%AggregateError%</ins>
</td>
<td>
<ins>`AggregateError`</ins>
</td>
<td>
<ins>The `AggregateError` constructor (<emu-xref href="#sec-aggregate-error-constructor"></emu-xref>)</ins>
</td>
</tr>
<tr>
<td>
<ins>%AggregateError.prototype%</ins>
</td>
<td>
<ins>`AggregateError.prototype`</ins>
</td>
<td>
<ins>The initial value of the `prototype` data property of %AggregateError%</ins>
chicoxyzzy marked this conversation as resolved.
Show resolved Hide resolved
</td>
</tr>
</tbody>
</table>
</emu-table>
</emu-clause>

<emu-clause id="sec-error-objects">
<h1>Error Objects</h1>
<p>Instances of Error objects are thrown as exceptions when runtime errors occur. The Error objects may also serve as base objects for user-defined exception classes.</p>
<p>When an ECMAScript implementation detects a runtime error, it throws a new instance of one of the _NativeError_ objects defined in <emu-xref href="#sec-native-error-types-used-in-this-standard"></emu-xref> or a new instance of %AggregateError%. Each of these objects has the structure described below, differing only in the name used as the constructor name instead of _NativeError_, in the `name` property of the prototype object, in the implementation-defined `message` property of the prototype object, and in the presence of the %AggregateError%-specific `errors` property.</p>
Copy link
Member

Choose a reason for hiding this comment

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

why is aggregate error not just another one of the native error types?

Copy link
Member Author

Choose a reason for hiding this comment

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

AggregateError has different constructor behavior than NativeErrors as @bakkot mention in #27

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I’m not sure that suggestion is in fact the best solution - it ends up duplicating a lot of spec text. Is there a way we could modify the NativeError approach so it could handle AggregateErrors?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that it's possible. Will try to figure out


<emu-clause id="sec-nativeerror-object-structure">
<h1>_NativeError_ Object Structure</h1>
<p>For each error object, references to _NativeError_ in the definition should be replaced with the appropriate error object name from <emu-xref href="#sec-native-error-types-used-in-this-standard"></emu-xref>.</p>

<emu-clause id="sec-properties-of-nativeerror-instances">
<h1>Properties of _NativeError_ Instances</h1>
<p>_NativeError_ instances are ordinary objects that inherit properties from their _NativeError_ prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is by `Object.prototype.toString` (<emu-xref href="#sec-object.prototype.tostring"></emu-xref>) to identify Error, _NativeError_, or _AggregateError_ instances.</p>
</emu-clause>
</emu-clause>


<emu-clause id="sec-aggregate-error-object-structure">
<h1>_AggregateError_ Object Structure</h1>
<p>For each error object, references to _AggregateError_ in the definition should be replaced with the appropriate error object name from <emu-xref href="#sec-aggregate-error-types-used-in-this-standard"></emu-xref>.</p>

<emu-clause id="sec-aggregate-error-constructor">
<h1>The _AggregateError_ Constructor</h1>
<p>The _AggregateError_ constructor:</p>
<ul>
<li>creates and initializes a new _AggregateError_ object when called as a function rather than as a constructor. A call of the object as a function is equivalent to calling it as a constructor with the same arguments. Thus the function call <code><var>AggregateError</var>(&hellip;)</code> is equivalent to the object creation expression <code>new <var>AggregateError</var>(&hellip;)</code> with the same arguments.</li>
<li>is designed to be subclassable. It may be used as the value of an `extends` clause of a class definition. Subclass constructors that intend to inherit the specified _AggregateError_ behaviour must include a `super` call to the _AggregateError_ constructor to create and initialize subclass instances with an [[ErrorData]] internal slot.</li>
</ul>

<emu-clause id="sec-aggregate-error">
<h1>AggregateError ( _errors_, _message_ )</h1>
<p>When the *AggregateError* function is called with arguments _errors_ and _message_, the following steps are taken:</p>
<emu-alg>
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
1. Let O be ? OrdinaryCreateFromConstructor(_newTarget_, `"%AggregateError.prototype%"`, « [[ErrorData]] »).
1. Let _errorsIterator_ be ? GetMethod(_errors_, @@iterator).
1. Let _errorsList_ ? IterableToList(_errors_, _errorsIterator_).
1. Let _errorsArray_ be CreateArrayFromList(_errorsList_).
1. Perform ! CreateDataProperty(_O_, `"errors"`, _errorsArray_).
chicoxyzzy marked this conversation as resolved.
Show resolved Hide resolved
1. If _message_ is not _undefined_, then
1. Let msg be ? ToString(_message_).
1. Let msgDesc be the PropertyDescriptor { [[Value]]: _msg_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
1. Perform ! DefinePropertyOrThrow(_O_, `"message"`, _msgDesc_).
chicoxyzzy marked this conversation as resolved.
Show resolved Hide resolved
1. Return _O_.
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-the-aggregateerror-constructors">
<h1>Properties of the _AggregateError_ Constructor</h1>
<p>The _AggregateError_ constructor:</p>
<ul>
<li>has a [[Prototype]] internal slot whose value is the intrinsic object %Error%.</li>
<li>has a `name` property whose value is the String value `"<var>AggregateError</var>"`.</li>
chicoxyzzy marked this conversation as resolved.
Show resolved Hide resolved
<li>has the following properties:</li>
</ul>

<emu-clause id="sec-aggregate-error.prototype">
<h1>AggregateError.prototype</h1>
<p>The initial value of <code><var>AggregateError</var>.prototype</code> is a _AggregateError_ prototype object (<emu-xref href="#sec-properties-of-the-aggregateerror-prototype-objects"></emu-xref>).</p>
<p>This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.</p>
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-the-aggregateerror-prototype-objects">
<h1>Properties of the _AggregateError_ Prototype Object</h1>
<p>The _AggregateError_ prototype object:</p>
<ul>
<li>is an ordinary object.</li>
<li>is not an Error instance and does not have an [[ErrorData]] internal slot.</li>
<li>has a [[Prototype]] internal slot whose value is the intrinsic object %Error.prototype%.</li>
</ul>

<emu-clause id="sec-aggregate-error.prototype.constructor">
<h1>_AggregateError_.prototype.constructor</h1>
<p>The initial value of the `AggregateError.prototype.constructor` is the intrinsic object %_AggregateError_% (<emu-xref href="#sec-aggregate-error-constructors"></emu-xref>).</p>
chicoxyzzy marked this conversation as resolved.
Show resolved Hide resolved
</emu-clause>

<emu-clause id="sec-aggregate-error.prototype.message">
<h1>_AggregateError_.prototype.message</h1>
chicoxyzzy marked this conversation as resolved.
Show resolved Hide resolved
<p>The initial value of the `AggregateError.prototypemessage` is the empty String.</p>
</emu-clause>

<emu-clause id="sec-aggregate-error.prototype.name">
<h1>_AggregateError_.prototype.name</h1>
chicoxyzzy marked this conversation as resolved.
Show resolved Hide resolved
<p>The initial value of the `AggregateError.prototypename` is the String value consisting of the name of the constructor (the name used instead of _AggregateError_).</p>
</emu-clause>

<emu-clause id="sec-aggregate-error.prototype.errors">
<h1>_AggregateError_.prototype.errors</h1>
Copy link
Member

Choose a reason for hiding this comment

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

repeating: there must not be a mutable object data property on the prototype.

AggregateError.prototype.errors must either be absent, a primitive, an accessor that returns a new array every time (either empty, or with the errors if #38 moves forward), or a data property using a frozen array.

Copy link
Member Author

@chicoxyzzy chicoxyzzy Sep 30, 2019

Choose a reason for hiding this comment

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

Should it be added to Properties of the _AggregateError_ Prototype Object part?

<p>The initial value of the `AggregateError.prototypeerrors` is an empty Array.</p>
chicoxyzzy marked this conversation as resolved.
Show resolved Hide resolved
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-aggregateerror-instances">
<h1>Properties of _AggregateError_ Instances</h1>
<p>_AggregateError_ instances are ordinary objects that inherit properties from their _AggregateError_ prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is by `Object.prototype.toString` (<emu-xref href="#sec-object.prototype.tostring"></emu-xref>) to identify Error, _NativeError_, or _AggregateError_ instances.</p>
</emu-clause>
</emu-clause>
</emu-clause>

<emu-clause id="sec-promise.any">
<h1>Promise.any ( _iterable_ )</h1>
<p>The `any` function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.</p>
Expand Down Expand Up @@ -130,53 +275,6 @@ <h1>ThrowAggregateError ( _errors_ )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-well-known-intrinsic-objects">
<h1>Well-Known Intrinsic Objects</h1>
<emu-table id="table-7" caption="Well-Known Intrinsic Objects">
<table>
<tbody>
<tr>
<th>
Intrinsic Name
</th>
<th>
Global Name
</th>
<th>
ECMAScript Language Association
</th>
</tr>
<tr>
<td>
<ins>%AggregateError%</ins>
</td>
<td>
<ins>`AggregateError`</ins>
</td>
<td>
<ins>The `AggregateError` constructor (<emu-xref href="#sec-native-error-types-used-in-this-standard-aggregateerror"></emu-xref>)</ins>
</td>
</tr>
</tbody>
</table>
</emu-table>
</emu-clause>

<emu-clause id="sec-native-error-types-used-in-this-standard-aggregateerror">
<h1>AggregateError ( errors, message )</h1>
<p>When the *AggregateError* function is called with arguments _errors_ and _message_, the following steps are taken:</p>
<emu-alg>
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
1. Let O be ? OrdinaryCreateFromConstructor(_newTarget_, `"%AggregateError.prototype%"`, « [[ErrorData]] »).
1. Let _errorsArray_ be ! CreateArrayFromList(? IterableToList(_errors_)).
1. Perform ! CreateMethodProperty(_O_, `"errors"`, _errorsArray_).
1. If _message_ is not _undefined_, then
1. Let msg be ? ToString(_message_).
1. Perform ! CreateMethodProperty(_O_, `"message"`, _msg_).
1. Return _O_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-iterabletolist" aoid="IterableToList">
<h1>Runtime Semantics: IterableToList ( _items_ <ins>[ ,</ins> _method_<ins> ]</ins> )</h1>
<p>The abstract operation IterableToList performs the following steps:</p>
Expand Down