tc39 / proposal-promise-any

ECMAScript proposal: Promise.any
https://tc39.es/proposal-promise-any/
200 stars 27 forks source link

Editorial: It's an error list there #30

Closed leobalter closed 5 years ago

leobalter commented 5 years ago

Clear the reference typo to _errors_ to match the other steps and use the name as it's a list, not an Array there.

leobalter commented 5 years ago

It seems like the line 1. Let _error_ be a newly createdAggregateErrorobject. should be called with errors as the first arg.

bakkot commented 5 years ago

Good catch! But since _errors_ is a list, not an array, I think the correct fix is to insert Let errorsArray be CreateArrayFromList(errorsList). before both of the Let error be a newly created AggregateError object. steps.

Re:

It seems like the line 1. Let _error_ be a newly created AggregateError object. should be called with errors as the first arg.

this line isn't actually calling the constructor, as I understand it; it leaves it to the host to decide how to produce the object (so that the host can add nonstandard properties like "stack"). Which is why it's explicitly defining the "errors" property.

leobalter commented 5 years ago

@bakkot thanks! Please review the fixup commit!

bakkot commented 5 years ago

@leobalter There's another instance of the same mistake in PerformPromiseAny 8.d.iii, which you could fix (in the same way) while you're at it

leobalter commented 5 years ago

done!

chicoxyzzy commented 5 years ago

It seems that generalization of this part could simplify maintain story:

  1. Let _errorsArray_ be CreateArrayFromList(_errors_).
  1. Let _error_ be a newly created `AggregateError` object.
  1. Perform ! CreateDataProperty ( _error_, `"errors"`, _errorsArray_ ).
  1. Return ThrowCompletion ( _error_ ).