Skip to content

Normative: Add Array.fromAsync #3581

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

Open
wants to merge 9 commits into
base: add-builtin-async-function-objects
Choose a base branch
from

Conversation

js-choi
Copy link
Contributor

@js-choi js-choi commented May 1, 2025

From proposal-array-from-async. Based on #2942 and tc39/proposal-array-from-async#50.

This is a draft for formal Stage 3 / 4 sign-offs (tc39/proposal-array-from-async#14) by the Editors, as per tc39/proposal-array-from-async#14 (comment).

There are currently several errors when building with ecmarkup 21.2.0. There are no more build errors except for a minor esmeta error, which is addressed by #3614.

CC: @syg, @bakkot, @michaelficarra

@js-choi js-choi marked this pull request as draft May 1, 2025 13:49
@bakkot
Copy link
Contributor

bakkot commented May 1, 2025

The error for IfAbruptCloseAsyncIterator is because you are already introducing it as an AO, which automatically defines the term, but you are also putting a <dfn> around the term. The second is unnecessary.

The errors like "Call returns a Completion Record, but is not consumed as if it does" refer to the convention that every completion-returning AO should be invoked as ? Foo(), ! Foo(), or Completion(Foo()) to make it clear to the reader that this AO returns a completion record. In these cases I think the intention is to treat the value as a completion record and not immediately unwrap, so the solution is to wrap the call in Completion() as in Let _mappedValue_ be Completion(Call(...)).

The failure of the "enforce format" job can be fixed by running "npm run format", as it says.

Most of the other errors are pretty clear, I think, but let me know if there's any that are not. We can address them ourselves if you don't get to them first.

@js-choi js-choi force-pushed the add-array-from-async branch 3 times, most recently from 2b41c14 to 2f2a9a9 Compare May 1, 2025 19:01
@js-choi js-choi force-pushed the add-array-from-async branch from 2f2a9a9 to b4c45be Compare May 1, 2025 19:13
@js-choi js-choi marked this pull request as ready for review May 1, 2025 19:22
@js-choi
Copy link
Contributor Author

js-choi commented May 1, 2025

ecmarkup / format errors have been fixed. This pull request is finally ready for Stage 3/4 sign-off from the Editors.

@nicolo-ribaudo, you might find this pull request more convenient to re-review than tc39/proposal-array-from-async#50 too.

There are minor build errors from esmeta that seem to be due to the algorithm’s use of the new IfAbruptCloseAsyncIterator operation.

We can do editorial refactoring later to make the algorithm use IteratorNext, IteratorComplete, and IteratorValue, like how Array.from now does.

Thanks to @bakkot for help, here and on Matrix.

@ljharb ljharb added normative change Affects behavior required to correctly evaluate some ECMAScript source text proposal This is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4. pending stage 4 This proposal has not yet achieved stage 4, but may otherwise be ready to merge. labels May 5, 2025
js-choi added a commit to js-choi/tc39-agendas that referenced this pull request May 5, 2025
Please note that the proposal-array-from-async proposal is out of date and still has a pending pull request (tc39/proposal-array-from-async#50). 

The most up-to-date version is the tc39/ecma262#3581 pull request linked in the table.
ljharb pushed a commit to js-choi/tc39-agendas that referenced this pull request May 6, 2025
Please note that the proposal-array-from-async proposal is out of date and still has a pending pull request (tc39/proposal-array-from-async#50).

The most up-to-date version is the tc39/ecma262#3581 pull request linked in the table.
@stonechoe
Copy link

If ESMeta doesn’t yet recognize the new operation, please feel free to ask us to add support rather than refactoring just to avoid build errors. If keeping IfAbruptCloseAsyncIterator makes the spec more readable than rewriting everything around IteratorNext, IteratorComplete, and IteratorValue, we’d prefer to leave it as-is. Let us know by opening an issue at ESMeta or dropping a comment, and we’ll get the new syntax supported.

There are minor build errors from esmeta that seem to be due to the algorithm’s use of the new IfAbruptCloseAsyncIterator operation.

We can do editorial refactoring later to make the algorithm use IteratorNext, IteratorComplete, and IteratorValue, like how Array.from now does.

@js-choi
Copy link
Contributor Author

js-choi commented May 28, 2025

As a courtesy to the editors reviewing this pull request, I would like to explicitly propose making the following editorial changes:

Copy link
Member

@michaelficarra michaelficarra left a comment

Choose a reason for hiding this comment

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

LGTM otherwise.

@michaelficarra
Copy link
Member

I would like to explicitly propose making the following editorial changes:

WFM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
normative change Affects behavior required to correctly evaluate some ECMAScript source text pending stage 4 This proposal has not yet achieved stage 4, but may otherwise be ready to merge. proposal This is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants