tc39 / proposal-array-from-async

Draft specification for a proposed Array.fromAsync method in JavaScript.
http://tc39.es/proposal-array-from-async/
BSD 3-Clause "New" or "Revised" License
177 stars 13 forks source link

Fix return type #12

Closed bakkot closed 2 years ago

bakkot commented 2 years ago

The current spec misuses ~return~ completions. Those are use for propagating a literal syntactic return in an ES function up through any intermediate syntax (which is handled by the ? macro) to the [[Call]] AO which invoked the function, where it is unwrapped into a normal completion (in step 10.2.1 of that algorithm).

Built-in functions do not need to deal with that propagation, so they can (and do) just return a normal completion holding the value in question directly. The [[Call]] semantics for built-in functions have no corresponding return->normal unwrapping.

(The current spec text ends up propagating a return completion to the caller - that is, as currently written, it would cause a return from the code which called fromAsync.)