-
Notifications
You must be signed in to change notification settings - Fork 27
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Please add yourself to the contributors:
at the top.
This looks great! I'll take a closer look soon. |
<h1>Runtime Semantics: PerformPromiseAny ( _iteratorRecord_, _constructor_, _resultCapability_ )</h1> | ||
<p>When the PerformPromiseAny abstract operation is called with arguments _iteratorRecord_, _constructor_, and _resultCapability_, the following steps are taken:</p> | ||
<emu-alg> | ||
1. Assert: ! IsConstructor(_constructor_) is *true*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an assertion about iteratorRecord?
1. Assert: ! IsConstructor(_constructor_) is *true*. | ||
1. Assert: _resultCapability_ is a PromiseCapability Record. | ||
1. Let _values_ be a new empty List. | ||
1. Let _remainingElementsCount_ be a new Record { [[Value]]: 1 }. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems weird to have a record here and pass it around. Is keeping a count like this the only solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at existing ECMAScript Specification Types, Record
is most suitable type here. It's used in other Promise
namespace functions as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sure, i wasn't suggesting a JS object or anything :-) more that, is passing around a counter the only viable approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I got it. Not sure to be honest 🤔 I need to do some more research to answer this question 🕵️♀️
<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_, `"%AggregateErrorPrototype%"`, « [[ErrorData]] »). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb should this be
1. Let O be ? OrdinaryCreateFromConstructor(_newTarget_, `"%AggregateErrorPrototype%"`, « [[ErrorData]] »). | |
1. Let O be ? OrdinaryCreateFromConstructor(_newTarget_, `"%AggregateError.prototype%"`, « [[ErrorData]] »). |
instead?
ref: https://github.com/tc39/ecma262/pull/1376/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chicoxyzzy once that PR lands, yes, it decidedly should be :-) until then, tho, you'd need to create a new intrinsic for the prototype for this spec to be correct.
1. Set _values_[_index_] to _x_. | ||
1. Set _remainingElementsCount_.[[Value]] to _remainingElementsCount_.[[Value]] - 1. | ||
1. If _remainingElementsCount_.[[Value]] is 0, then | ||
1. Let _valuesArray_ be CreateArrayFromList(_values_). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should be something like
Let _valuesArray_ be AggregateError(_values_, ???).
I'm not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't yet have a convention for how to specify an error object which has a required property. I think I would do something like
1. Let _errorsArray_ be CreateArrayFromList(_values_).
1. Let _exception_ be a newly created AggregateError object.
1. Perform ! CreateDataProperty(_exception_, `"errors"`, _errorsArray_).
1. Return ? Call(*undefined*, _promiseCapability_.[[Reject]], « _exception_ »).
The "a newly created WhateverError object" phrasing is used elsewhere. Doing it this way hopefully makes it clear that engines are required to provide .errors
but are free to make message
whatever they feel is appropriate, just as with other errors thrown by builtins.
I just added spec text for |
I’ll merge this as-is and we can take it from there. Thanks! |
AggregateError
is not implemented in this version yet. I'll add it when we'll reach an agreement on#14 and current text.
update:
AggregateError
added