From e94a501c99a653c9411599ebada67d72258d6b44 Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Thu, 11 Jan 2018 11:55:56 -0800 Subject: [PATCH 01/44] Normative: Add AsyncIteration --- spec.html | 1065 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 1037 insertions(+), 28 deletions(-) diff --git a/spec.html b/spec.html index 2c14d3e2f7..f235fb25cb 100644 --- a/spec.html +++ b/spec.html @@ -982,6 +982,17 @@

Well-Known Symbols

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ @@asyncIterator + + `"Symbol.asyncIterator"` + + A method that returns the default AsyncIterator for an object. Called by the semantics of the `for`-`await`-`of` statement. +
Specification Name @@ -1832,6 +1843,16 @@

Well-Known Intrinsic Objects

The initial value of the `values` data property of %ArrayPrototype% ()
+ %AsyncFromSyncIteratorPrototype% + + + The prototype of async-from-sync iterator objects () +
%AsyncFunction% @@ -1852,6 +1873,46 @@

Well-Known Intrinsic Objects

The initial value of the `prototype` data property of %AsyncFunction%
+ %AsyncGenerator% + + + The initial value of the `prototype` property of %AsyncGeneratorFunction% +
+ %AsyncGeneratorFunction% + + + The constructor of async iterator objects () +
+ %AsyncGeneratorPrototype% + + + The initial value of the `prototype` property of %AsyncGenerator% +
+ %AsyncIteratorPrototype% + + + An object that all standard built-in async iterator objects indirectly inherit from +
%Atomics% @@ -2978,6 +3039,93 @@

The Completion Record Specification Type

The term “abrupt completion” refers to any completion with a [[Type]] value other than ~normal~.

+ +

Await

+ + +

The AsyncFunctionAwait abstract operation could probably be refactored in terms of this primitive.

+
+ +

Algorithm steps that say

+ + + 1. Let _completion_ be Await(_promise_). + + +

mean the same thing as:

+ + + 1. Let _asyncContext_ be the running execution context. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _promise_ »). + 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Let _onRejected_ be a new built-in function object as defined in . + 1. Set _onFulfilled_ and _onRejected_'s [[AsyncContext]] internal slots to _asyncContext_. + 1. Let _throwawayCapability_ be NewPromiseCapability(%Promise%). + 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. + 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). + 1. Remove _asyncContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. + 1. Set the code evaluation state of _asyncContext_ such that when evaluation is resumed with a Completion _completion_, the following steps of the algorithm that invoked Await will be performed, with _completion_ available. + + +

where all variables in the above steps, with the exception of _completion_, are ephemeral and visible only in the steps pertaining to Await.

+ + +

Await can be combined with the `?` and `!` prefixes, so that for example

+ + + 1. Let _value_ be ? Await(_promise_). + + +

means the same thing as:

+ + + 1. Let _value_ be Await(_promise_). + 1. ReturnIfAbrupt(_value_). + +
+ + +

Await Fulfilled Functions

+ +

An Await fulfilled function is an anonymous built-in function that is used as part of the Await specification device to deliver the promise fulfillment value to the caller as a normal completion. Each Await fulfilled function has an [[AsyncContext]] internal slot.

+ +

When an Await fulfilled function _F_ is called with argument _value_, the following steps are taken:

+ + + 1. Let _asyncContext_ be _F_.[[AsyncContext]]. + 1. Let _prevContext_ be the running execution context. + 1. Suspend _prevContext_. + 1. Push _asyncContext_ onto the execution context stack; _asyncContext_ is now the running execution context. + 1. Resume the suspended evaluation of _asyncContext_ using NormalCompletion(_value_) as the result of the operation that suspended it. + 1. Assert: When we reach this step, _asyncContext_ has already been removed from the execution context stack and _prevContext_ is the currently running execution context. + 1. Return *undefined*. + + +

The `length` property of an Await fulfilled function is 1.

+
+ + +

Await Rejected Functions

+ +

An Await rejected function is an anonymous built-in function that is used as part of the Await specification device to deliver the promise rejection reason to the caller as an abrupt throw completion. Each Await rejected function has an [[AsyncContext]] internal slot.

+ +

When an Await rejected function _F_ is called with argument _reason_, the following steps are taken:

+ + + 1. Let _asyncContext_ be _F_.[[AsyncContext]]. + 1. Let _prevContext_ be the running execution context. + 1. Suspend _prevContext_. + 1. Push _asyncContext_ onto the execution context stack; _asyncContext_ is now the running execution context. + 1. Resume the suspended evaluation of _asyncContext_ using Completion{[[Type]]: ~throw~, [[Value]]: _reason_, [[Target]]: ~empty~} as the result of the operation that suspended it. + 1. Assert: When we reach this step, _asyncContext_ has already been removed from the execution context stack and _prevContext_ is the currently running execution context. + 1. Return *undefined*. + + +

The `length` property of an Await rejected function is 1.

+
+
+

NormalCompletion

@@ -4813,13 +4961,38 @@

CopyDataProperties (_target_, _source_, _excludedItems_)

Operations on Iterator Objects

See Common Iteration Interfaces ().

+ +

AsyncIteratorClose ( _iteratorRecord_, _completion_ )

+

The abstract operation AsyncIteratorClose with arguments _iteratorRecord_ and _completion_ is used to notify an async iterator that it should perform any actions it would normally perform when it has reached its completed state:

+ + 1. Assert: Type(_iteratorRecord_.[[Iterator]]) is Object. + 1. Assert: _completion_ is a Completion Record. + 1. Let _iterator_ be _iteratorRecord_.[[Iterator]]. + 1. Let _return_ be ? GetMethod(_iterator_, `"return"`). + 1. If _return_ is *undefined*, return Completion(_completion_). + 1. Let _innerResult_ be Call(_return_, _iterator_, « »). + 1. If _innerResult_.[[Type]] is ~normal~, set _innerResult_ to Await(_innerResult_.[[Value]]). + 1. If _completion_.[[Type]] is ~throw~, return Completion(_completion_). + 1. If _innerResult_.[[Type]] is ~throw~, return Completion(_innerResult_). + 1. If Type(_innerResult_.[[Value]]) is not Object, throw a *TypeError* exception. + 1. Return Completion(_completion_). + +
+ -

GetIterator ( _obj_ [ , _method_ ] )

+

GetIterator ( _obj_ [ , _hint_ ] [ , _method_ ] )

The abstract operation GetIterator with argument _obj_ and optional argument _method_ performs the following steps:

+ 1. If _hint_ was not passed, let _hint_ be ~normal~. 1. If _method_ is not present, then - 1. Set _method_ to ? GetMethod(_obj_, @@iterator). + 1. If _hint_ is ~async~, + 1. Set _method_ to ? GetMethod(_obj_, @@asyncIterator). + 1. If _method_ is *undefined*, + 1. Let _syncMethod_ be ? GetMethod(_obj_, @@iterator). + 1. Let _syncIteratorRecord_ be ? GetIterator(_obj_, ~normal~, _syncMethod_). + 1. Return ? CreateAsyncFromSyncIterator(_syncIteratorRecord_). + 1. Otherwise, set _method_ to ? GetMethod(_obj_, @@iterator). 1. Let _iterator_ be ? Call(_method_, _obj_). 1. If Type(_iterator_) is not Object, throw a *TypeError* exception. 1. Let _nextMethod_ be ? GetV(_iterator_, `"next"`). @@ -7415,6 +7588,16 @@

[[Construct]] ( _argumentsList_, _newTarget_ )

+ +

AsyncGeneratorFunctionCreate (_kind_, _ParameterList_, _Body_, _Scope_, _Strict_)

+

The abstract operation AsyncGeneratorFunctionCreate requires the arguments: _kind_ which is one of (~Normal~, ~Method~), a parameter list production specified by _ParameterList_, a body production specified by _Body_, a Lexical Environment specified by _Scope_, and a Boolean flag _Strict_. AsyncGeneratorFunctionCreate performs the following steps:

+ + 1. Let _functionPrototype_ be the intrinsic object %AsyncGenerator%. + 1. Let _F_ be ! FunctionAllocate(_functionPrototype_, _Strict_, `"generator"`). + 1. Return ! FunctionInitialize(_F_, _kind_, _ParameterList_, _Body_, _Scope_). + +
+

FunctionAllocate ( _functionPrototype_, _strict_, _functionKind_ )

@@ -14765,7 +14948,14 @@

Syntax

BreakableStatement[Yield, Await, Return] : IterationStatement[?Yield, ?Await, ?Return] SwitchStatement[?Yield, ?Await, ?Return] + + ReturnStatement[Yield, Await] : + `return` `;` + `return` [no LineTerminator here] Expression[+In, ?Yield, ?Await] `;` + +

A `return` statement causes a function to cease execution and return a value to the caller. If |Expression| is omitted, the return value is *undefined*. Otherwise, the return value is the value of |Expression|.

+
@@ -16249,6 +16439,9 @@

Syntax

`for` `(` [lookahead != `let` ] LeftHandSideExpression[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return] `for` `(` `var` ForBinding[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return] `for` `(` ForDeclaration[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return] + [+Await] `for` `await` `(` [lookahead != `let` ] LeftHandSideExpression[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return] + [+Await] `for` `await` `(` `var` ForBinding[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return] + [+Await] `for` `await` `(` ForDeclaration[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return] ForDeclaration[Yield, Await] : LetOrConst ForBinding[?Yield, ?Await] @@ -16281,6 +16474,9 @@

Static Semantics: Early Errors

`for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement
  • @@ -16652,7 +16848,7 @@

    Runtime Semantics: CreatePerIterationEnvironment( _perIterationBindings_ ) -

    The `for`-`in` and `for`-`of` Statements

    +

    The `for`-`in`, `for`-`of`, and `for`-`await`-`of` Statements

    @@ -16661,6 +16857,7 @@

    Static Semantics: Early Errors

    IterationStatement : `for` `(` LeftHandSideExpression `in` Expression `)` Statement `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement
    • @@ -16683,6 +16880,7 @@

      Static Semantics: Early Errors

      IterationStatement : `for` `(` ForDeclaration `in` Expression `)` Statement `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement
      • @@ -16720,6 +16918,10 @@

        Static Semantics: ContainsDuplicateLabels

        `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement + 1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. @@ -16742,6 +16944,9 @@

        Static Semantics: ContainsUndefinedBreakTarget

        `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. @@ -16764,6 +16969,9 @@

        Static Semantics: ContainsUndefinedContinueTarget

        `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». @@ -16812,17 +17020,29 @@

        Static Semantics: VarDeclaredNames

        1. Return the VarDeclaredNames of |Statement|. - IterationStatement : `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + + IterationStatement : + `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + 1. Return the VarDeclaredNames of |Statement|. - IterationStatement : `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + + IterationStatement : + `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + 1. Let _names_ be the BoundNames of |ForBinding|. 1. Append to _names_ the elements of the VarDeclaredNames of |Statement|. 1. Return _names_. - IterationStatement : `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + + IterationStatement : + `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement + 1. Return the VarDeclaredNames of |Statement|. @@ -16845,21 +17065,37 @@

        Static Semantics: VarScopedDeclarations

        1. Append to _declarations_ the elements of the VarScopedDeclarations of |Statement|. 1. Return _declarations_.
        - IterationStatement : `for` `(` ForDeclaration `in` Expression `)` Statement + + IterationStatement : + `for` `(` ForDeclaration `in` Expression `)` Statement + `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + 1. Return the VarScopedDeclarations of |Statement|. - IterationStatement : `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + + IterationStatement : + `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + 1. Return the VarScopedDeclarations of |Statement|. - IterationStatement : `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + + IterationStatement : + `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + 1. Let _declarations_ be a List containing |ForBinding|. 1. Append to _declarations_ the elements of the VarScopedDeclarations of |Statement|. 1. Return _declarations_. - IterationStatement : `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + + IterationStatement : + `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement + `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement + 1. Return the VarScopedDeclarations of |Statement|. @@ -16933,6 +17169,27 @@

        Runtime Semantics: LabelledEvaluation

        1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(BoundNames of |ForDeclaration|, |AssignmentExpression|, ~iterate~). 1. Return ? ForIn/OfBodyEvaluation(|ForDeclaration|, |Statement|, _keyResult_, ~iterate~, ~lexicalBinding~, _labelSet_).
        + + IterationStatement : `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement + + + 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(« », |AssignmentExpression|, ~async-iterate~). + 1. Return ? ForIn/OfBodyEvaluation(|LeftHandSideExpression|, |Statement|, _keyResult_, ~assignment~, _labelSet_, ~async~). + + + IterationStatement : `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement + + + 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(« », |AssignmentExpression|, ~async-iterate~). + 1. Return ? ForIn/OfBodyEvaluation(|ForBinding|, |Statement|, _keyResult_, ~varBinding~, _labelSet_, ~async~). + + + IterationStatement : `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement + + + 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(BoundNames of |ForDeclaration|, |AssignmentExpression|, ~async-iterate~). + 1. Return ? ForIn/OfBodyEvaluation(|ForDeclaration|, |Statement|, _keyResult_, ~lexicalBinding~, _labelSet_, ~async~). +

        This section is extended by Annex .

        @@ -16961,15 +17218,18 @@

        Runtime Semantics: ForIn/OfHeadEvaluation ( _TDZnames_, _expr_, _iterationKi 1. Return ? EnumerateObjectProperties(_obj_). 1. Else, 1. Assert: _iterationKind_ is ~iterate~. - 1. Return ? GetIterator(_exprValue_). + 1. If _iterationKind_ is ~async-iterate~, let _iteratorHint_ be ~async~. + 1. Else, let _iteratorHint_ be ~normal~. + 1. Return ? GetIterator(_exprValue_, _iteratorHint_). -

        Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_ )

        -

        The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, and _labelSet_. The value of _iterationKind_ is either ~enumerate~ or ~iterate~. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~.

        +

        Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_ [ , _iteratorKind_ ])

        +

        The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _lhsKind_, labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~normal~ or ~async~.

        + 1. If _iteratorKind_ was not passed, let _iteratorKind_ be ~normal~. 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. 1. Let _V_ be *undefined*. 1. Let _destructuring_ be IsDestructuring of _lhs_. @@ -16977,8 +17237,9 @@

        Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, 1. Assert: _lhs_ is a |LeftHandSideExpression|. 1. Let _assignmentPattern_ be the |AssignmentPattern| that is covered by _lhs_. 1. Repeat, - 1. Let _nextResult_ be ? IteratorStep(_iteratorRecord_). - 1. If _nextResult_ is *false*, return NormalCompletion(_V_). + 1. Let _nextResult_ be ? Call(_iteratorRecord_.[[NextMethod]], _iteratorRecord_.[[Iterator]], « »). + 1. If _iteratorKind_ is ~async~, then set _nextResult_ to ? Await(_nextResult_). + 1. If Type(_nextResult_) is not Object, throw a *TypeError* exception. 1. Let _nextValue_ be ? IteratorValue(_nextResult_). 1. If _lhsKind_ is either ~assignment~ or ~varBinding~, then 1. If _destructuring_ is *false*, then @@ -17012,6 +17273,7 @@

        Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, 1. Let _status_ be the result of performing BindingInitialization for _lhs_ passing _nextValue_ and _iterationEnv_ as arguments. 1. If _status_ is an abrupt completion, then 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. If _iteratorKind_ is ~async~, return ? AsyncIteratorClose(_iteratorRecord_, _status_). 1. If _iterationKind_ is ~enumerate~, then 1. Return _status_. 1. Else, @@ -17206,6 +17468,7 @@

        Runtime Semantics: Evaluation

        1. Let _exprRef_ be the result of evaluating |Expression|. 1. Let _exprValue_ be ? GetValue(_exprRef_). + 1. If ! GetGeneratorKind() is ~async~, set _exprValue_ to ? Await(_exprValue_). 1. Return Completion{[[Type]]: ~return~, [[Value]]: _exprValue_, [[Target]]: ~empty~}.
        @@ -19179,6 +19442,7 @@

        Static Semantics: SpecialMethod

        MethodDefinition : GeneratorMethod + AsyncGeneratorMethod AsyncMethod `get` PropertyName `(` `)` `{` FunctionBody `}` `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` @@ -19542,58 +19806,333 @@

        Runtime Semantics: Evaluation

        YieldExpression : `yield` - 1. Return ? GeneratorYield(CreateIterResultObject(*undefined*, *false*)). + 1. Let _generatorKind_ be ! GetGeneratorKind(). + 1. If _generatorKind_ is ~async~, then return ? AsyncGeneratorYield(*undefined*). + 1. Otherwise, return ? GeneratorYield(CreateIterResultObject(*undefined*, *false*)). YieldExpression : `yield` AssignmentExpression + 1. Let _generatorKind_ be ! GetGeneratorKind(). 1. Let _exprRef_ be the result of evaluating |AssignmentExpression|. 1. Let _value_ be ? GetValue(_exprRef_). - 1. Return ? GeneratorYield(CreateIterResultObject(_value_, *false*)). + 1. If _generatorKind_ is ~async~, then return ? AsyncGeneratorYield(_value_). + 1. Otherwise, return ? GeneratorYield(CreateIterResultObject(_value_, *false*)). YieldExpression : `yield` `*` AssignmentExpression + 1. Let _generatorKind_ be ! GetGeneratorKind(). 1. Let _exprRef_ be the result of evaluating |AssignmentExpression|. 1. Let _value_ be ? GetValue(_exprRef_). - 1. Let _iteratorRecord_ be ? GetIterator(_value_). + 1. Let _iteratorRecord_ be ? GetIterator(_value_, _generatorKind_). 1. Let _iterator_ be _iteratorRecord_.[[Iterator]]. 1. Let _received_ be NormalCompletion(*undefined*). 1. Repeat, 1. If _received_.[[Type]] is ~normal~, then - 1. Let _innerResult_ be ? IteratorNext(_iteratorRecord_, _received_.[[Value]]). + 1. Let _innerResult_ be ? Call(_iteratorRecord_.[[NextMethod]], _iteratorRecord_.[[Iterator]], « _received_.[[Value]] »). + 1. If _generatorKind_ is ~async~, then set _innerResult_ to ? Await(_innerResult_). + 1. If Type(_innerResult_) is not Object, throw a *TypeError* exception. 1. Let _done_ be ? IteratorComplete(_innerResult_). 1. If _done_ is *true*, then 1. Return ? IteratorValue(_innerResult_). - 1. Set _received_ to GeneratorYield(_innerResult_). + 1. If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)). + 1. Else, let _received_ be GeneratorYield(_innerResult_). 1. Else if _received_.[[Type]] is ~throw~, then 1. Let _throw_ be ? GetMethod(_iterator_, `"throw"`). 1. If _throw_ is not *undefined*, then 1. Let _innerResult_ be ? Call(_throw_, _iterator_, « _received_.[[Value]] »). + 1. If _generatorKind_ is ~async~, then set _innerResult_ to ? Await(_innerResult_). 1. NOTE: Exceptions from the inner iterator `throw` method are propagated. Normal completions from an inner `throw` method are processed similarly to an inner `next`. 1. If Type(_innerResult_) is not Object, throw a *TypeError* exception. 1. Let _done_ be ? IteratorComplete(_innerResult_). 1. If _done_ is *true*, then 1. Return ? IteratorValue(_innerResult_). - 1. Set _received_ to GeneratorYield(_innerResult_). + 1. If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)). + 1. Else, let _received_ be GeneratorYield(_innerResult_). 1. Else, 1. NOTE: If _iterator_ does not have a `throw` method, this throw is going to terminate the `yield*` loop. But first we need to give _iterator_ a chance to clean up. - 1. Perform ? IteratorClose(_iteratorRecord_, Completion{[[Type]]: ~normal~, [[Value]]: ~empty~, [[Target]]: ~empty~}). + 1. Let _closeCompletion_ be Completion{[[Type]]: ~normal~, [[Value]]: ~empty~, [[Target]]: ~empty~}. + 1. If _generatorKind_ is ~async~, perform ? AsyncIteratorClose(_iteratorRecord_, _closeCompletion_). + 1. Else, perform ? IteratorClose(_iteratorRecord_, _closeCompletion_). 1. NOTE: The next step throws a *TypeError* to indicate that there was a `yield*` protocol violation: _iterator_ does not have a `throw` method. 1. Throw a *TypeError* exception. 1. Else, 1. Assert: _received_.[[Type]] is ~return~. 1. Let _return_ be ? GetMethod(_iterator_, `"return"`). - 1. If _return_ is *undefined*, return Completion(_received_). + 1. If _return_ is *undefined*, then: + 1. If _generatorKind_ is ~async~, then set _received_.[[Value]] to ? Await(_received_.[[Value]]). + 1. Return Completion(_received_). 1. Let _innerReturnResult_ be ? Call(_return_, _iterator_, « _received_.[[Value]] »). + 1. If _generatorKind_ is ~async~, then set _innerReturnResult_ to ? Await(_innerReturnResult_). 1. If Type(_innerReturnResult_) is not Object, throw a *TypeError* exception. 1. Let _done_ be ? IteratorComplete(_innerReturnResult_). 1. If _done_ is *true*, then 1. Let _value_ be ? IteratorValue(_innerReturnResult_). 1. Return Completion{[[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~}. - 1. Set _received_ to GeneratorYield(_innerReturnResult_). + 1. If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)). + 1. Else, let _received_ be GeneratorYield(_innerResult_). + +

        Async Generator Function Definitions

        +

        Syntax

        + + AsyncGeneratorMethod[Yield, Await] : + `async` [no LineTerminator here] `*` PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, +Await] `)` `{` AsyncGeneratorBody `}` + + AsyncGeneratorDeclaration[Yield, Await, Default] : + `async` [no LineTerminator here] `function` `*` BindingIdentifier[?Yield, ?Await] `(` FormalParameters[+Yield, +Await] `)` `{` AsyncGeneratorBody `}` + [+Default] `async` [no LineTerminator here] `function` `*` `(` FormalParameters[+Yield, +Await] `)` `{` AsyncGeneratorBody `}` + + AsyncGeneratorExpression : + `async` [no LineTerminator here] `function` `*` BindingIdentifier[+Yield, +Await]? `(` FormalParameters[+Yield, +Await] `)` `{` AsyncGeneratorBody `}` + + AsyncGeneratorBody : + FunctionBody[+Yield, +Await] + + +

        |YieldExpression| and |AwaitExpression| cannot be used within the |FormalParameters| of an async generator function because any expressions that are part of |FormalParameters| are evaluated before the resulting async generator object is in a resumable state.

        +
        + +

        Abstract operations relating to async generator objects are defined in .

        +
        + + +

        Static Semantics: Early Errors

        + AsyncGeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` +
          +
        • It is a Syntax Error if HasDirectSuper of |AsyncGeneratorMethod| is *true*.
        • +
        • It is a Syntax Error if |UniqueFormalParameters| Contains |YieldExpression| is *true*.
        • +
        • It is a Syntax Error if |UniqueFormalParameters| Contains |AwaitExpression| is *true*.
        • +
        • It is a Syntax Error if ContainsUseStrict of |AsyncGeneratorBody| is *true* and IsSimpleParameterList of |UniqueFormalParameters| is *false*.
        • +
        • It is a Syntax Error if any element of the BoundNames of |UniqueFormalParameters| also occurs in the LexicallyDeclaredNames of |AsyncGeneratorBody|.
        • +
        + + AsyncGeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + AsyncGeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + AsyncGeneratorDeclaration : `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + +
          +
        • If the source code matching this production is strict mode code, the Early Error rules for UniqueFormalParameters : FormalParameters are applied.
        • +
        • If the source code matching this production is strict mode code, it is a Syntax Error if |BindingIdentifier| is the |IdentifierName| `eval` or the |IdentifierName| `arguments`.
        • +
        • It is a Syntax Error if ContainsUseStrict of |AsyncGeneratorBody| is *true* and IsSimpleParameterList of |FormalParameters| is *false*.
        • +
        • It is a Syntax Error if any element of the BoundNames of |FormalParameters| also occurs in the LexicallyDeclaredNames of |AsyncGeneratorBody|.
        • +
        • It is a Syntax Error if |FormalParameters| Contains |YieldExpression| is *true*.
        • +
        • It is a Syntax Error if |FormalParameters| Contains |AwaitExpression| is *true*.
        • +
        • It is a Syntax Error if |FormalParameters| Contains |SuperProperty| is *true*.
        • +
        • It is a Syntax Error if |AsyncGeneratorBody| Contains |SuperProperty| is *true*.
        • +
        • It is a Syntax Error if |FormalParameters| Contains |SuperCall| is *true*.
        • +
        • It is a Syntax Error if |AsyncGeneratorBody| Contains |SuperCall| is *true*.
        • +
        +
        + + +

        Static Semantics: BoundNames

        + + AsyncGeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + 1. Return the BoundNames of |BindingIdentifier|. + + AsyncGeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + 1. Return « `"*default*"` ». + + +

        `"*default*"` is used within this specification as a synthetic name for hoistable anonymous functions that are defined using export declarations.

        +
        +
        + + +

        Static Semantics: ComputedPropertyContains

        +

        With parameter _symbol_.

        + + AsyncGeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + + 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. + +
        + + +

        Static Semantics: Contains

        +

        With parameter _symbol_.

        + + + AsyncGeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + AsyncGeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + AsyncGeneratorExpression : `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + + 1. Return *false*. + + +

        Static semantic rules that depend upon substructure generally do not look into function definitions.

        +
        +
        + + +

        Static Semantics: HasDirectSuper

        + + AsyncGeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + + 1. If |UniqueFormalParameters| Contains |SuperCall| is *true*, return *true*. + 1. Return |AsyncGeneratorBody| Contains |SuperCall|. + +
        + + +

        Static Semantics: HasName

        + + AsyncGeneratorExpression : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + 1. Return *false*. + + AsyncGeneratorExpression : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + 1. Return *true*. + +
        + + +

        Static Semantics: IsConstantDeclaration

        + + + AsyncGeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + AsyncGeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + + 1. Return *false*. + +
        + + +

        Static Semantics: IsFunctionDefinition

        + + AsyncGeneratorExpression : `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + 1. Return *true*. + +
        + + +

        Static Semantics: PropName

        + + AsyncGeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + + 1. Return PropName of |PropertyName|. + +
        + + +

        Runtime Semantics: EvaluateBody

        +

        With parameters _functionObject_ and List _argumentsList_.

        + + AsyncGeneratorBody : FunctionBody + + + 1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_). + 1. Let _generator_ be ? OrdinaryCreateFromConstructor(_functionObject_, `"%AsyncGeneratorPrototype%"`, « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]] »). + 1. Perform ! AsyncGeneratorStart(_generator_, _FunctionBody_). + 1. Return Completion{[[Type]]: ~return~, [[Value]]: _generator_, [[Target]]: ~empty~}. + +
        + + +

        Runtime Semantics: InstantiateFunctionObject

        +

        With parameter _scope_.

        + + AsyncGeneratorDeclaration : `async` [no LineTerminator here] `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + + 1. If the function code for |AsyncGeneratorDeclaration| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*. + 1. Let _name_ be StringValue of |BindingIdentifier|. + 1. Let _F_ be ! AsyncGeneratorFunctionCreate(~Normal~, |FormalParameters|, |AsyncGeneratorBody|, _scope_, _strict_). + 1. Let _prototype_ be ! ObjectCreate(%AsyncGeneratorPrototype%). + 1. Perform ! DefinePropertyOrThrow(_F_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}). + 1. Perform ! SetFunctionName(_F_, _name_). + 1. Return _F_. + + + + AsyncGeneratorDeclaration : `async` [no LineTerminator here] `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + + 1. If the function code for |AsyncGeneratorDeclaration| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*. + 1. Let _F_ be AsyncGeneratorFunctionCreate(~Normal~, |FormalParameters|, |AsyncGeneratorBody|, _scope_, _strict_). + 1. Let _prototype_ be ObjectCreate(%AsyncGeneratorPrototype%). + 1. Perform DefinePropertyOrThrow(_F_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}). + 1. Perform SetFunctionName(_F_, `"default"`). + 1. Return _F_. + + +

        An anonymous |AsyncGeneratorDeclaration| can only occur as part of an `export default` declaration.

        +
        +
        + + +

        Runtime Semantics: PropertyDefinitionEvaluation

        +

        With parameter _object_ and _enumerable_.

        + + AsyncGeneratorMethod : `async` [no LineTerminator here] `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + + + 1. Let _propKey_ be the result of evaluating |PropertyName|. + 1. ReturnIfAbrupt(_propKey_). + 1. If the function code for this |AsyncGeneratorMethod| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*. + 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _closure_ be ! AsyncGeneratorFunctionCreate(~Method~, |UniqueFormalParameters|, |AsyncGeneratorBody|, _scope_, _strict_). + 1. Perform ! MakeMethod(_closure_, _object_). + 1. Let _prototype_ be ! ObjectCreate(%AsyncGeneratorPrototype%). + 1. Perform ! DefinePropertyOrThrow(_closure_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}). + 1. Perform ! SetFunctionName(_closure_, _propKey_). + 1. Let _desc_ be PropertyDescriptor{[[Value]]: _closure_, [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true*}. + 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_). + +
        + + +

        Runtime Semantics: Evaluation

        + + + AsyncGeneratorExpression : `async` [no LineTerminator here] `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + + 1. If the function code for this |AsyncGeneratorExpression| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*. + 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _closure_ be ! AsyncGeneratorFunctionCreate(~Normal~, |FormalParameters|, |AsyncGeneratorBody|, _scope_, _strict_). + 1. Let _prototype_ be ! ObjectCreate(%AsyncGeneratorPrototype%). + 1. Perform ! DefinePropertyOrThrow(_closure_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}). + 1. Return _closure_. + + + + AsyncGeneratorExpression : `async` [no LineTerminator here] `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + + 1. If the function code for this |AsyncGeneratorExpression| is strict mode code, let _strict_ be *true*. Otherwise let _strict_ be *false*. + 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _funcEnv_ be ! NewDeclarativeEnvironment(_scope_). + 1. Let _envRec_ be _funcEnv_'s EnvironmentRecord. + 1. Let _name_ be StringValue of |BindingIdentifier|. + 1. Perform ! _envRec_.CreateImmutableBinding(_name_). + 1. Let _closure_ be ! AsyncGeneratorFunctionCreate(~Normal~, |FormalParameters|, |AsyncGeneratorBody|, _funcEnv_, _strict_). + 1. Let _prototype_ be ! ObjectCreate(%AsyncGeneratorPrototype%). + 1. Perform ! DefinePropertyOrThrow(_closure_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}). + 1. Perform ! SetFunctionName(_closure_, _name_). + 1. Perform ! _envRec_.InitializeBinding(_name_, _closure_). + 1. Return _closure_. + + +

        The |BindingIdentifier| in an |AsyncGeneratorExpression| can be referenced from inside the |AsyncGeneratorExpression|'s |AsyncGeneratorBody| to allow the generator code to call itself recursively. However, unlike in an |AsyncGeneratorDeclaration|, the |BindingIdentifier| in an |AsyncGeneratorExpression| cannot be referenced from and does not affect the scope enclosing the |AsyncGeneratorExpression|.

        +
        +
        +
        +

        Class Definitions

        @@ -24707,7 +25246,7 @@

        Function ( _p1_, _p2_, … , _pn_, _body_ )

        Runtime Semantics: CreateDynamicFunction( _constructor_, _newTarget_, _kind_, _args_ )

        -

        The abstract operation CreateDynamicFunction is called with arguments _constructor_, _newTarget_, _kind_, and _args_. _constructor_ is the constructor function that is performing this action, _newTarget_ is the constructor that `new` was initially applied to, _kind_ is either `"normal"`, `"generator"`, or `"async"`, and _args_ is a List containing the actual argument values that were passed to _constructor_. The following steps are taken:

        +

        The abstract operation CreateDynamicFunction is called with arguments _constructor_, _newTarget_, _kind_, and _args_. _constructor_ is the constructor function that is performing this action, _newTarget_ is the constructor that `new` was initially applied to, _kind_ is either `"normal"`, `"generator"`, `"async"`, or `"async generator"`, and _args_ is a List containing the actual argument values that were passed to _constructor_. The following steps are taken:

        1. Assert: The execution context stack has at least two elements. 1. Let _callerContext_ be the second to top element of the execution context stack. @@ -24723,11 +25262,16 @@

        Runtime Semantics: CreateDynamicFunction( _constructor_, _newTarget_, _kind_ 1. Let _goal_ be the grammar symbol |GeneratorBody|. 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[+Yield, ~Await]|. 1. Let _fallbackProto_ be `"%Generator%"`. - 1. Else, + 1. Else if _kind_ is `"async"`, 1. Assert: _kind_ is `"async"`. 1. Let _goal_ be the grammar symbol |AsyncFunctionBody|. 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[~Yield, +Await]|. 1. Let _fallbackProto_ be `"%AsyncFunctionPrototype%"`. + 1. Else, + 1. Assert: _kind_ is `"async generator"` + 1. Let _goal_ be the grammar symbol |AsyncGeneratorBody|. + 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[+Yield, +Await]|. + 1. Let _fallbackProto_ be `"%AsyncGenerator%"`. 1. Let _argCount_ be the number of elements in _args_. 1. Let _P_ be the empty String. 1. If _argCount_ = 0, let _bodyText_ be the empty String. @@ -24753,9 +25297,9 @@

        Runtime Semantics: CreateDynamicFunction( _constructor_, _newTarget_, _kind_ 1. If _parameters_ Contains |SuperCall| is *true*, throw a *SyntaxError* exception. 1. If _body_ Contains |SuperProperty| is *true*, throw a *SyntaxError* exception. 1. If _parameters_ Contains |SuperProperty| is *true*, throw a *SyntaxError* exception. - 1. If _kind_ is `"generator"`, then + 1. If _kind_ is `"generator"` or `"async generator"`, then 1. If _parameters_ Contains |YieldExpression| is *true*, throw a *SyntaxError* exception. - 1. If _kind_ is `"async"`, then + 1. If _kind_ is `"async"` or `"async generator"`, then 1. If _parameters_ Contains |AwaitExpression| is *true*, throw a *SyntaxError* exception. 1. If _strict_ is *true*, then 1. If BoundNames of _parameters_ contains any duplicate elements, throw a *SyntaxError* exception. @@ -24767,6 +25311,9 @@

        Runtime Semantics: CreateDynamicFunction( _constructor_, _newTarget_, _kind_ 1. If _kind_ is `"generator"`, then 1. Let _prototype_ be ObjectCreate(%GeneratorPrototype%). 1. Perform DefinePropertyOrThrow(_F_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}). + 1. Else if _kind_ is `"async generator"`, then + 1. Let _prototype_ be ObjectCreate(%AsyncGeneratorPrototype%). + 1. Perform DefinePropertyOrThrow(_F_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}). 1. Else if _kind_ is `"normal"`, perform MakeConstructor(_F_). 1. NOTE: Async functions are not constructable and do not have a [[Construct]] internal method or a `"prototype"` property. 1. Perform SetFunctionName(_F_, `"anonymous"`). @@ -25164,6 +25711,12 @@

        Symbol.iterator

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

        + +

        Symbol.asyncIterator

        +

        The initial value of `Symbol.asyncIterator` is the well known symbol @@asyncIterator ().

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

        +
        +

        Symbol.keyFor ( _sym_ )

        @@ -36781,6 +37334,91 @@

        The Iterator Interface

        + +

        Common Iteration Interfaces

        + + +

        The AsyncIterable Interface

        +

        The AsyncIterable interface includes the properties described in :

        + + + + + + + + + + + + + + +
        PropertyValueRequirements
        `@@asyncIterator`A function that returns an AsyncIterator object.The returned object must conform to the AsyncIterator interface.
        +
        +
        + + +

        The AsyncIterator Interface

        +

        An object that implements the AsyncIterator interface must include the properties in . Such objects may also implement the properties in .

        + + + + + + + + + + + + + + +
        PropertyValueRequirements
        `next`A function that returns a promise for an IteratorResult object. +

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. If a previous call to the `next` method of an AsyncIterator has returned a promise for an IteratorResult object whose `done` property is *true*, then all subsequent calls to the `next` method of that object should also return a promise for an IteratorResult object whose `done` property is *true*. However, this requirement is not enforced.

        + +

        Additionally, the IteratorResult object that serves as a fulfillment value should have a `value` property whose value is not a promise (or "thenable"). However, this requirement is also not enforced.

        +
        +
        + +

        Arguments may be passed to the next function but their interpretation and validity is dependent upon the target AsyncIterator. The `for`-`await`-`of` statement and other common users of AsyncIterators do not pass any arguments, so AsyncIterator objects that expect to be used in such a manner must be prepared to deal with being called with no arguments.

        +
        + + + + + + + + + + + + + + + + + + + +
        PropertyValueRequirements
        `return`A function that returns a promise for an IteratorResult object. +

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. Invoking this method notifies the AsyncIterator object that the caller does not intend to make any more `next` method calls to the AsyncIterator. The returned promise will fulfill with an IteratorResult object which will typically have a `done` property whose value is *true*, and a `value` property with the value passed as the argument of the `return` method. However, this requirement is not enforced.

        + +

        Additionally, the IteratorResult object that serves as a fulfillment value should have a `value` property whose value is not a promise (or "thenable"). If the argument value is used in the typical manner, then if it is a rejected promise, a promise rejected with the same reason should be returned; if it is a fulfilled promise, then its fulfillment value should be used as the `value` property of the returned promise's IteratorResult object fulfillment value. However, these requirements are also not enforced.

        +
        `throw`A function that returns a promise for an IteratorResult object. +

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. Invoking this method notifies the AsyncIterator object that the caller has detected an error condition. The argument may be used to identify the error condition and typically will be an exception object. A typical response is to return a rejected promise which rejects with the value passed as the argument.

        + +

        If the returned promise is fulfilled, the IteratorResult fulfillment value will typically have a `done` property whose value is *true*. Additionally, it should have a `value` property whose value is not a promise (or "thenable"), but this requirement is not enforced.

        +
        +
        + +

        Typically callers of these methods should check for their existence before invoking them. Certain ECMAScript language features including `for`-`await`-`of` and `yield*` call these methods after performing an existence check.

        +
        +
        +
        +

        The IteratorResult Interface

        @@ -36849,6 +37487,184 @@

        %IteratorPrototype% [ @@iterator ] ( )

        + +

        The %AsyncIteratorPrototype% Object

        +

        The value of the [[Prototype]] internal slot of the %AsyncIteratorPrototype% object is the intrinsic object %ObjectPrototype%. The %AsyncIteratorPrototype% object is an ordinary object. The initial value of the [[Extensible]] internal slot of the %AsyncIteratorPrototype% object is *true*.

        + +

        All objects defined in this specification that implement the AsyncIterator interface also inherit from %AsyncIteratorPrototype%. ECMAScript code may also define objects that inherit from %AsyncIteratorPrototype%.The %AsyncIteratorPrototype% object provides a place where additional methods that are applicable to all async iterator objects may be added.

        +
        + + +

        %AsyncIteratorPrototype% [ @@asyncIterator ] ( )

        +

        The following steps are taken:

        + + 1. Return the *this* value. + +

        The value of the `name` property of this function is `"[Symbol.asyncIterator]"`.

        +
        +
        + + +

        Async-from-Sync Iterator Objects

        +

        An Async-from-Sync Iterator object is an async iterator that adapts a specific synchronous iterator. There is not a named constructor for Async-from-Sync Iterator objects. Instead, Async-from-Sync iterator objects are created by the CreateAsyncFromSyncIterator abstract operation as needed.

        + + +

        CreateAsyncFromSyncIterator(_syncIteratorRecord_) Abstract Operation

        +

        The abstract operation CreateAsyncFromSyncIterator is used to create an async iterator Record from a synchronous iterator Record. It performs the following steps:

        + + 1. Let _asyncIterator_ be ! ObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »). + 1. Set _asyncIterator_.[[SyncIteratorRecord]] to _syncIteratorRecord_. + 1. Return ? GetIterator(_asyncIterator_, ~async~). + +
        + + +

        The %AsyncFromSyncIteratorPrototype% Object

        +

        All Async-from-Sync Iterator Objects inherit properties from the %AsyncFromSyncIteratorPrototype% intrinsic object. The %AsyncFromSyncIteratorPrototype% object is an ordinary object and its [[Prototype]] internal slot is the %AsyncIteratorPrototype% intrinsic object. In addition, %AsyncFromSyncIteratorPrototype% has the following properties:

        + + +

        %AsyncFromSyncIteratorPrototype%.next ( _value_ )

        + + 1. Let _O_ be the *this* value. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then + 1. Let _badIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]]. + 1. Let _nextResult_ be IteratorNext(_syncIteratorRecord_, _value_). + 1. IfAbruptRejectPromise(_nextResult_, _promiseCapability_). + 1. Let _nextDone_ be IteratorComplete(_nextResult_). + 1. IfAbruptRejectPromise(_nextDone_, _promiseCapability_). + 1. Let _nextValue_ be IteratorValue(_nextResult_). + 1. IfAbruptRejectPromise(_nextValue_, _promiseCapability_). + 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). + 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _nextValue_ »). + 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Set _onFulfilled_.[[Done]] to _nextDone_. + 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). + 1. Return _promiseCapability_.[[Promise]]. + +
        + + +

        %AsyncFromSyncIteratorPrototype%.return ( _value_ )

        + + + 1. Let _O_ be the *this* value. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then + 1. Let _badIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. + 1. Let _return_ be GetMethod(_syncIterator_, `"return"`). + 1. IfAbruptRejectPromise(_return_, _promiseCapability_). + 1. If _return_ is *undefined*, then + 1. Let _iterResult_ be ! CreateIterResultObject(_value_, *true*). + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _iterResult_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _returnResult_ be Call(_return_, _syncIterator_, « _value_ »). + 1. IfAbruptRejectPromise(_returnResult_, _promiseCapability_). + 1. If Type(_returnResult_) is not *Object*, + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _returnDone_ be IteratorComplete(_returnResult_). + 1. IfAbruptRejectPromise(_returnDone_, _promiseCapability_). + 1. Let _returnValue_ be IteratorValue(_returnResult_). + 1. IfAbruptRejectPromise(_returnValue_, _promiseCapability_). + 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). + 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _returnValue_ »). + 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Set _onFulfilled_.[[Done]] to _returnDone_. + 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). + 1. Return _promiseCapability_.[[Promise]]. + +
        + + +

        %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

        + + + 1. Let _O_ be the *this* value. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then + 1. Let _badIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. + 1. Let _throw_ be GetMethod(_syncIterator_, `"throw"`). + 1. IfAbruptRejectPromise(_throw_, _promiseCapability_). + 1. If _throw_ is *undefined*, then + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _value_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _throwResult_ be Call(_throw_, _syncIterator_, « _value_ »). + 1. IfAbruptRejectPromise(_throwResult_, _promiseCapability_). + 1. If Type(_throwResult_) is not *Object*, + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _throwDone_ be IteratorComplete(_throwResult_). + 1. IfAbruptRejectPromise(_throwDone_, _promiseCapability_). + 1. Let _throwValue_ be IteratorValue(_throwResult_). + 1. IfAbruptRejectPromise(_throwValue_, _promiseCapability_). + 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). + 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _throwValue_ »). + 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Set _onFulfilled_.[[Done]] to _throwDone_. + 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). + 1. Return _promiseCapability_.[[Promise]]. + +
        + + +

        %AsyncFromSyncIteratorPrototype% [ @@toStringTag ]

        +

        The initial value of the @@toStringTag property is the String value `"Async-from-Sync Iterator"`.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        + + +

        Async-from-Sync Iterator Value Unwrap Functions

        + +

        An async-from-sync iterator value unwrap function is an anonymous built-in function that is used by methods of %AsyncFromSyncIteratorPrototype% when processing the `value` field of an IteratorResult object, in order to wait for its value if it is a promise and re-package the result in a new "unwrapped" IteratorResult object. Each async iterator value unwrap function has a [[Done]] internal slot.

        + +

        When an async-from-sync iterator value unwrap function _F_ is called with argument _value_, the following steps are taken:

        + + + 1. Return ! CreateIterResultObject(_value_, _F_.[[Done]]). + +
        +
        + + +

        Properties of Async-from-Sync Iterator Instances

        +

        Async-from-Sync Iterator instances are ordinary objects that inherit properties from the %AsyncFromSyncIteratorPrototype% intrinsic object. Async-from-Sync Iterator instances are initially created with the internal slots listed in .

        + + + + + + + + + + + + + + +
        + Internal Slot + + Description +
        + [[SyncIteratorRecord]] + + A Record, of the type returned by GetIterator, representing the original synchronous iterator which is being adapted. +
        +
        +
        +
        +

        GeneratorFunction Objects

        @@ -36959,6 +37775,100 @@

        prototype

        + +

        Generator Objects

        +

        AsyncGenerator Function objects are functions that are usually created by evaluating |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, and |AsyncGeneratorMethod| syntactic productions. They may also be created by calling the %AsyncGeneratorFunction% intrinsic.

        + + +

        The AsyncGeneratorFunction Constructor

        +

        The `AsyncGeneratorFunction` constructor is the %AsyncGeneratorFunction% intrinsic. When `AsyncGeneratorFunction` is called as a function rather than as a constructor, it creates and initializes a new AsyncGeneratorFunction object. Thus the function call `AsyncGeneratorFunction (...)` is equivalent to the object creation expression `new AsyncGeneratorFunction (...)` with the same arguments.

        +

        `AsyncGeneratorFunction` 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 `AsyncGeneratorFunction` behaviour must include a `super` call to the `AsyncGeneratorFunction` constructor to create and initialize subclass instances with the internal slots necessary for built-in AsyncGeneratorFunction behaviour. All ECMAScript syntactic forms for defining async generator function objects create direct instances of `AsyncGeneratorFunction`. There is no syntactic means to create instances of `AsyncGeneratorFunction` subclasses.

        + + +

        AsyncGeneratorFunction ( _p1_, _p2_, ..., _pn_, _body_ )

        +

        The last argument specifies the body (executable code) of an async generator function; any preceding arguments specify formal parameters.

        +

        When the `AsyncGeneratorFunction` function is called with some arguments _p1_, _p2_, … , _pn_, _body_ (where _n_ might be 0, that is, there are no "_p_" arguments, and where _body_ might also not be provided), the following steps are taken:

        + + 1. Let _C_ be the active function object. + 1. Let _args_ be the _argumentsList_ that was passed to this function by [[Call]] or [[Construct]]. + 1. Return ? CreateDynamicFunction(_C_, NewTarget, `"async generator"`, _args_). + + +

        See NOTE for .

        +
        +
        +
        + + +

        Properties of the AsyncGeneratorFunction Constructor

        +

        The `AsyncGeneratorFunction` constructor is a standard built-in function object that inherits from the `Function` constructor. The value of the [[Prototype]] internal slot of the `AsyncGeneratorFunction` constructor is the intrinsic object %Function%.

        +

        The value of the [[Extensible]] internal slot of the AsyncGeneratorFunction constructor is *true*.

        +

        The value of the `name` property of the AsyncGeneratorFunction is `"AsyncGeneratorFunction"`.

        +

        The `AsyncGeneratorFunction` constructor has the following properties:

        + + +

        AsyncGeneratorFunction.length

        +

        This is a data property with a value of 1. This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        + + +

        AsyncGeneratorFunction.prototype

        +

        The initial value of `AsyncGeneratorFunction.prototype` is the intrinsic object %AsyncGenerator%.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

        +
        +
        + + +

        Properties of the AsyncGeneratorFunction Prototype Object

        +

        The AsyncGeneratorFunction prototype object is an ordinary object. It is not a function object and does not have an [[ECMAScriptCode]] internal slot or any other of the internal slots listed in or . In addition to being the value of the prototype property of the %AsyncGeneratorFunction% intrinsic, it is the %AsyncGenerator% intrinsic.

        +

        The value of the [[Prototype]] internal slot of the AsyncGeneratorFunction prototype object is the %FunctionPrototype% intrinsic object. The initial value of the [[Extensible]] internal slot of the AsyncGeneratorFunction prototype object is *true*.

        + + +

        AsyncGeneratorFunction.prototype.constructor

        +

        The initial value of `AsyncGeneratorFunction.prototype.constructor` is the intrinsic object %AsyncGeneratorFunction%.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        + + +

        AsyncGeneratorFunction.prototype.prototype

        +

        The value of `AsyncGeneratorFunction.prototype.prototype` is the %AsyncGeneratorPrototype% intrinsic object.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        + + +

        AsyncGeneratorFunction.prototype [ @@toStringTag ]

        +

        The initial value of the @@toStringTag property is the String value `"AsyncGeneratorFunction"`.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        +
        + + +

        AsyncGeneratorFunction Instances

        +

        Every AsyncGeneratorFunction instance is an ECMAScript function object and has the internal slots listed in . The value of the [[FunctionKind]] internal slot for all such instances is `"generator"`.

        +

        Each AsyncGeneratorFunction instance has the following own properties:

        + + +

        length

        +

        The value of the `length` property is an integer that indicates the typical number of arguments expected by the AsyncGeneratorFunction. However, the language permits the function to be invoked with some other number of arguments. The behaviour of an AsyncGeneratorFunction when invoked on a number of arguments other than the number specified by its `length` property depends on the function.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        + + +

        name

        +

        The specification for the `name` property of Function instances given in also applies to AsyncGeneratorFunction instances.

        +
        + + +

        prototype

        +

        Whenever an AsyncGeneratorFunction instance is created another ordinary object is also created and is the initial value of the async generator function's `prototype` property. The value of the prototype property is used to initialize the [[Prototype]] internal slot of a newly created AsyncGenerator object when the generator function object is invoked using [[Call]].

        +

        This property has the attributes { [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

        + +

        Unlike function instances, the object that is the value of the an AsyncGeneratorFunction's `prototype` property does not have a `constructor` property whose value is the AsyncGeneratorFunction instance.

        +
        +
        +
        +
        +

        Generator Objects

        @@ -37145,6 +38055,17 @@

        GeneratorResumeAbrupt ( _generator_, _abruptCompletion_ )

        + +

        GetGeneratorKind ( )

        + + 1. Let _genContext_ be the running execution context. + 1. If _genContext_ does not have a Generator component, return ~non-generator~. + 1. Let _generator_ be the Generator component of _genContext_. + 1. If _generator_ has an [[AsyncGeneratorState]] internal slot, return ~async~. + 1. Else, return ~normal~. + +
        +

        GeneratorYield ( _iterNextObj_ )

        @@ -37154,6 +38075,7 @@

        GeneratorYield ( _iterNextObj_ )

        1. Let _genContext_ be the running execution context. 1. Assert: _genContext_ is the execution context of a generator. 1. Let _generator_ be the value of the Generator component of _genContext_. + 1. Assert: GetGeneratorKind() is ~normal~. 1. Set _generator_.[[GeneratorState]] to `"suspendedYield"`. 1. Remove _genContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. 1. Set the code evaluation state of _genContext_ such that when evaluation is resumed with a Completion _resumptionValue_ the following steps will be performed: @@ -37166,6 +38088,93 @@

        GeneratorYield ( _iterNextObj_ )

        + +

        AsyncGenerator Objects

        +

        An AsyncGenerator object is an instance of an async generator function and conforms to both the AsyncIterator and AsyncIterable interfaces.

        + +

        AsyncGenerator instances directly inherit properties from the object that is the value of the `prototype` property of the AsyncGenerator function that created the instance. AsyncGenerator instances indirectly inherit properties from the AsyncGenerator Prototype intrinsic, %AsyncGeneratorPrototype%.

        + + +

        Properties of AsyncGenerator Prototype

        +

        The AsyncGenerator prototype object is the %AsyncGeneratorPrototype% intrinsic. It is also the initial value of the `prototype` property of the %AsyncGenerator% intrinsic (the AsyncGeneratorFunction.prototype).

        +

        The AsyncGenerator prototype is an ordinary object. It is not an AsyncGenerator instance and does not have an [[AsyncGeneratorState]] internal slot.

        +

        The value of the [[Prototype]] internal slot of the AsyncGenerator prototype object is the intrinsic object %AsyncIteratorPrototype%. The initial value of the [[Extensible]] internal slot of the AsyncGenerator prototype object is *true*.

        +

        All AsyncGenerator instances indirectly inherit properties of the AsyncGenerator prototype object.

        + + +

        AsyncGenerator.prototype.constructor

        +

        The initial value of `AsyncGenerator.prototype.constructor` is the intrinsic object %AsyncGenerator%.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        + + +

        AsyncGenerator.prototype.next ( _value_ )

        + + 1. Let _generator_ be the `this` value. + 1. Let _completion_ be NormalCompletion(_value_). + 1. Return ! AsyncGeneratorEnqueue(_generator_, _completion_). + +
        + + +

        AsyncGenerator.prototype.return ( _value_ )

        + + 1. Let _generator_ be the `this` value. + 1. Let _completion_ be Completion{[[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~}. + 1. Return ! AsyncGeneratorEnqueue(_generator_, _completion_). + +
        + + +

        AsyncGenerator.prototype.throw ( _exception_ )

        + + 1. Let _generator_ be the `this` value. + 1. Let _completion_ be Completion{[[Type]]: ~throw~, [[Value]]: _exception_, [[Target]]: ~empty~}. + 1. Return ! AsyncGeneratorEnqueue(_generator_, _completion_). + +
        + + +

        AsyncGenerator.prototype [ @@toStringTag ]

        +

        The initial value of the @@toStringTag property is the String value `"AsyncGenerator"`.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        + +
        + + +

        Properties of AsyncGenerator Instances

        +

        AsyncGenerator instances are initially created with the internal slots described below:

        + + + + + + + + + + + + + + + + + + + + +
        Internal SlotDescription
        [[AsyncGeneratorState]]The current execution state of the async generator. The possible values are: *undefined*, `"suspendedStart"`, `"suspendedYield"`, `"executing"`, `"awaiting-return"`, and `"completed"`.
        [[AsyncGeneratorContext]]The execution context that is used when executing the code of this async generator.
        [[AsyncGeneratorQueue]]A List of AsyncGeneratorRequest records which represent requests to resume the async generator.
        +
        +
        + + +

        AsyncGenerator Abstract Operations

        + +
        +
        +

        Promise Objects

        From 65f2d54cc3caba8e47b659a1496207956ea3f36e Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:30:12 -0500 Subject: [PATCH 02/44] Add missing abstract-operations.html contents --- spec.html | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 198 insertions(+), 1 deletion(-) diff --git a/spec.html b/spec.html index f235fb25cb..522e8424c5 100644 --- a/spec.html +++ b/spec.html @@ -38171,7 +38171,204 @@

        Properties of AsyncGenerator Instances

        AsyncGenerator Abstract Operations

        - + +

        AsyncGeneratorRequest Records

        +

        The AsyncGeneratorRequest is a Record value used to store information about how an async generator should be resumed and contains capabilities for fulfilling or rejecting the corresponding promise.

        +

        They have the following fields:

        + + + + + + + + + + + + + + + + + + + +
        Field NameValueMeaning
        [[Completion]]A Completion recordThe completion which should be used to resume the async generator.
        [[Capability]]A PromiseCapability recordThe promise capabilities associated with this request.
        +
        +
        + + +

        AsyncGeneratorStart ( _generator_, _generatorBody_ )

        + + 1. Assert: _generator_ is an AsyncGenerator instance. + 1. Assert: _generator_.[[AsyncGeneratorState]] is *undefined*. + 1. Let _genContext_ be the running execution context. + 1. Set the Generator component of _genContext_ to _generator_. + 1. Set the code evaluation state of _genContext_ such that when evaluation is resumed for that execution context the following steps will be performed: + 1. Let _result_ be the result of evaluating _generatorBody_. + 1. Assert: If we return here, the async generator either threw an exception or performed either an implicit or explicit return. + 1. Remove _genContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. + 1. Set _generator_.[[AsyncGeneratorState]] to `"completed"`. + 1. If _result_ is a normal completion, let _resultValue_ be *undefined*. + 1. Else, + 1. Let _resultValue_ be _result_.[[Value]]. + 1. If _result_.[[Type]] is not ~return~, then + 1. Return ! AsyncGeneratorReject(_generator_, _resultValue_). + 1. Return ! AsyncGeneratorResolve(_generator_, _resultValue_, *true*). + 1. Set _generator_.[[AsyncGeneratorContext]] to _genContext_. + 1. Set _generator_.[[AsyncGeneratorState]] to `"suspendedStart"`. + 1. Set _generator_.[[AsyncGeneratorQueue]] to a new empty List. + 1. Return *undefined*. + +
        + + +

        AsyncGeneratorResolve ( _generator_, _value_, _done_ )

        + + 1. Assert: _generator_ is an AsyncGenerator instance. + 1. Let _queue_ be _generator_.[[AsyncGeneratorQueue]]. + 1. Assert: _queue_ is not an empty List. + 1. Remove the first element from _queue_ and let _next_ be the value of that element. + 1. Let _promiseCapability_ be _next_.[[Capability]]. + 1. Let _iteratorResult_ be ! CreateIterResultObject(_value_, _done_). + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _iteratorResult_ »). + 1. Perform ! AsyncGeneratorResumeNext(_generator_). + 1. Return *undefined*. +
        + + + +

        AsyncGeneratorReject ( _generator_, _exception_ )

        + + 1. Assert: _generator_ is an AsyncGenerator instance. + 1. Let _queue_ be _generator_.[[AsyncGeneratorQueue]]. + 1. Assert: _queue_ is not an empty List. + 1. Remove the first element from _queue_ and let _next_ be the value of that element. + 1. Let _promiseCapability_ be _next_.[[Capability]]. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _exception_ »). + 1. Perform ! AsyncGeneratorResumeNext(_generator_). + 1. Return *undefined*. + +
        + + +

        AsyncGeneratorResumeNext ( _generator_ )

        + + 1. Assert: _generator_ is an AsyncGenerator instance. + 1. Let _state_ be _generator_.[[AsyncGeneratorState]]. + 1. Assert: _state_ is not `"executing"`. + 1. If _state_ is `"awaiting-return"`, return *undefined*. + 1. Let _queue_ be _generator_.[[AsyncGeneratorQueue]]. + 1. If _queue_ is an empty List, return *undefined*. + 1. Let _next_ be the value of the first element of _queue_. + 1. Assert: _next_ is an AsyncGeneratorRequest record. + 1. Let _completion_ be _next_.[[Completion]]. + 1. If _completion_ is an abrupt completion, then + 1. If _state_ is `"suspendedStart"`, then + 1. Set _generator_.[[AsyncGeneratorState]] to `"completed"`. + 1. Set _state_ to `"completed"`. + 1. If _state_ is `"completed"`, then + 1. If _completion_.[[Type]] is ~return~: + 1. Set _generator_.[[AsyncGeneratorState]] to `"awaiting-return"`. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _completion_.[[Value]] »). + 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Let _onRejected_ be a new built-in function object as defined in . + 1. Set _onFulfilled_ and _onRejected_'s [[Generator]] internal slots to _generator_. + 1. Let _throwawayCapability_ be NewPromiseCapability(%Promise%). + 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. + 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). + 1. Return *undefined*. + 1. Else, + 1. Assert: _completion_.[[Type]] is ~throw~. + 1. Perform ! AsyncGeneratorReject(_generator_, _completion_.[[Value]]). + 1. Return *undefined*. + 1. Else if _state_ is `"completed"`, then return ! AsyncGeneratorResolve(_generator_, *undefined*, *true*). + 1. Assert: _state_ is either `"suspendedStart"` or `"suspendedYield"`. + 1. Let _genContext_ be _generator_.[[AsyncGeneratorContext]]. + 1. Let _callerContext_ be the running execution context. + 1. Suspend _callerContext_. + 1. Set _generator_.[[AsyncGeneratorState]] to `"executing"`. + 1. Push _genContext_ onto the execution context stack; _genContext_ is now the running execution context. + 1. Resume the suspended evaluation of _genContext_ using _completion_ as the result of the operation that suspended it. Let _result_ be the completion record returned by the resumed computation. + 1. Assert: _result_ is never an abrupt completion. + 1. Assert: When we return here, _genContext_ has already been removed from the execution context stack and _callerContext_ is the currently running execution context. + 1. Return *undefined*. + + + +

        AsyncGeneratorResumeNext Return Processor Fulfilled Functions

        + +

        An AsyncGeneratorResumeNext return processor fulfilled function is an anonymous built-in function that is used as part of the AsyncGeneratorResumeNext specification device to unwrap promises passed in to the method. Each AsyncGeneratorResumeNext return processor fulfilled function has a [[Generator]] internal slot.

        + +

        When an AsyncGeneratorResumeNext return processor fulfilled function _F_ is called with argument _value_, the following steps are taken:

        + + + 1. Set _F_.[[Generator]].[[AsyncGeneratorState]] to `"completed"`. + 1. Return ! AsyncGeneratorResolve(_F_.[[Generator]], _value_, *true*). + + +

        The `length` property of an AsyncGeneratorResumeNext return processor fulfilled function is 1.

        +
        + + +

        AsyncGeneratorResumeNext Return Processor Rejected Functions

        + +

        An AsyncGeneratorResumeNext return processor rejected function is an anonymous built-in function that is used as part of the AsyncGeneratorResumeNext specification device to unwrap promises passed in to the method. Each AsyncGeneratorResumeNext return processor rejected function has a [[Generator]] internal slot.

        + +

        When an AsyncGeneratorResumeNext return processor rejected function _F_ is called with argument _reason_, the following steps are taken:

        + + + 1. Set _F_.[[Generator]].[[AsyncGeneratorState]] to `"completed"`. + 1. Return ! AsyncGeneratorReject(_F_.[[Generator]], _reason_). + + +

        The `length` property of an AsyncGeneratorResumeNext return processor rejected function is 1.

        +
        +
        + + +

        AsyncGeneratorEnqueue ( _generator_, _completion_ )

        + + 1. Assert: _completion_ is a Completion Record. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. If Type(_generator_) is not Object, or if _generator_ does not have an [[AsyncGeneratorState]] internal slot, then + 1. Let _badGeneratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badGeneratorError_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _queue_ be _generator_.[[AsyncGeneratorQueue]]. + 1. Let _request_ be AsyncGeneratorRequest{[[Completion]]: _completion_, [[Capability]]: _promiseCapability_}. + 1. Append _request_ to the end of _queue_. + 1. Let _state_ be _generator_.[[AsyncGeneratorState]]. + 1. If _state_ is not `"executing"`, then + 1. Perform ! AsyncGeneratorResumeNext(_generator_). + 1. Return _promiseCapability_.[[Promise]]. + +
        + + +

        AsyncGeneratorYield ( _value_ )

        +

        The abstract operation AsyncGeneratorYield with argument _value_ performs the following steps:

        + + 1. Let _genContext_ be the running execution context. + 1. Assert: _genContext_ is the execution context of a generator. + 1. Let _generator_ be the value of the Generator component of _genContext_. + 1. Assert: GetGeneratorKind() is ~async~. + 1. Set _value_ to ? Await(_value_). + 1. Set _generator_.[[AsyncGeneratorState]] to `"suspendedYield"`. + 1. Remove _genContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. + 1. Set the code evaluation state of _genContext_ such that when evaluation is resumed with a Completion _resumptionValue_ the following steps will be performed: + 1. If _resumptionValue_.[[Type]] is not ~return~, return Completion(_resumptionValue_). + 1. Let _awaited_ be Await(_resumptionValue_.[[Value]]). + 1. If _awaited_.[[Type]] is ~throw~, return Completion(_awaited_). + 1. Assert: _awaited_.[[Type]] is ~normal~. + 1. Return Completion{[[Type]]: ~return~, [[Value]]: _awaited_.[[Value]], [[Target]]: ~empty~}. + 1. NOTE: When one of the above steps returns, it returns to the evaluation of the |YieldExpression| production that originally called this abstract operation. + 1. Return ! AsyncGeneratorResolve(_generator_, _value_, *false*). + 1. NOTE: This returns to the evaluation of the operation that had most previously resumed evaluation of _genContext_. + +
        From 4fb365846e6ad4d25b5390a855810aba61233427 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:33:25 -0500 Subject: [PATCH 03/44] Remove from headings --- spec.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec.html b/spec.html index 522e8424c5..6b5e908149 100644 --- a/spec.html +++ b/spec.html @@ -4962,7 +4962,7 @@

        Operations on Iterator Objects

        See Common Iteration Interfaces ().

        -

        AsyncIteratorClose ( _iteratorRecord_, _completion_ )

        +

        AsyncIteratorClose ( _iteratorRecord_, _completion_ )

        The abstract operation AsyncIteratorClose with arguments _iteratorRecord_ and _completion_ is used to notify an async iterator that it should perform any actions it would normally perform when it has reached its completed state:

        1. Assert: Type(_iteratorRecord_.[[Iterator]]) is Object. @@ -7589,7 +7589,7 @@

        [[Construct]] ( _argumentsList_, _newTarget_ )

        -

        AsyncGeneratorFunctionCreate (_kind_, _ParameterList_, _Body_, _Scope_, _Strict_)

        +

        AsyncGeneratorFunctionCreate (_kind_, _ParameterList_, _Body_, _Scope_, _Strict_)

        The abstract operation AsyncGeneratorFunctionCreate requires the arguments: _kind_ which is one of (~Normal~, ~Method~), a parameter list production specified by _ParameterList_, a body production specified by _Body_, a Lexical Environment specified by _Scope_, and a Boolean flag _Strict_. AsyncGeneratorFunctionCreate performs the following steps:

        1. Let _functionPrototype_ be the intrinsic object %AsyncGenerator%. @@ -25712,8 +25712,8 @@

        Symbol.iterator

        -

        Symbol.asyncIterator

        -

        The initial value of `Symbol.asyncIterator` is the well known symbol @@asyncIterator ().

        +

        Symbol.asyncIterator

        +

        The initial value of `Symbol.asyncIterator` is the well known symbol @@asyncIterator ().

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

        @@ -37338,7 +37338,7 @@

        The Iterator Interface

        Common Iteration Interfaces

        -

        The AsyncIterable Interface

        +

        The AsyncIterable Interface

        The AsyncIterable interface includes the properties described in :

        @@ -37359,7 +37359,7 @@

        The AsyncIterable Interface

        -

        The AsyncIterator Interface

        +

        The AsyncIterator Interface

        An object that implements the AsyncIterator interface must include the properties in . Such objects may also implement the properties in .

        @@ -37488,7 +37488,7 @@

        %IteratorPrototype% [ @@iterator ] ( )

        -

        The %AsyncIteratorPrototype% Object

        +

        The %AsyncIteratorPrototype% Object

        The value of the [[Prototype]] internal slot of the %AsyncIteratorPrototype% object is the intrinsic object %ObjectPrototype%. The %AsyncIteratorPrototype% object is an ordinary object. The initial value of the [[Extensible]] internal slot of the %AsyncIteratorPrototype% object is *true*.

        All objects defined in this specification that implement the AsyncIterator interface also inherit from %AsyncIteratorPrototype%. ECMAScript code may also define objects that inherit from %AsyncIteratorPrototype%.The %AsyncIteratorPrototype% object provides a place where additional methods that are applicable to all async iterator objects may be added.

        @@ -37505,7 +37505,7 @@

        %AsyncIteratorPrototype% [ @@asyncIterator ] ( )

        -

        Async-from-Sync Iterator Objects

        +

        Async-from-Sync Iterator Objects

        An Async-from-Sync Iterator object is an async iterator that adapts a specific synchronous iterator. There is not a named constructor for Async-from-Sync Iterator objects. Instead, Async-from-Sync iterator objects are created by the CreateAsyncFromSyncIterator abstract operation as needed.

        @@ -38056,7 +38056,7 @@

        GeneratorResumeAbrupt ( _generator_, _abruptCompletion_ )

        -

        GetGeneratorKind ( )

        +

        GetGeneratorKind ( )

        1. Let _genContext_ be the running execution context. 1. If _genContext_ does not have a Generator component, return ~non-generator~. @@ -38348,7 +38348,7 @@

        AsyncGeneratorEnqueue ( _generator_, _completion_ )

        -

        AsyncGeneratorYield ( _value_ )

        +

        AsyncGeneratorYield ( _value_ )

        The abstract operation AsyncGeneratorYield with argument _value_ performs the following steps:

        1. Let _genContext_ be the running execution context. From da2a1b5f6a743cb2ec0fd1d201d4f9b3eabc23be Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:37:28 -0500 Subject: [PATCH 04/44] Replace AsyncFunctionAwait with Await --- spec.html | 63 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/spec.html b/spec.html index 6b5e908149..53e6573418 100644 --- a/spec.html +++ b/spec.html @@ -3042,10 +3042,6 @@

        The Completion Record Specification Type

        Await

        - -

        The AsyncFunctionAwait abstract operation could probably be refactored in terms of this primitive.

        -
        -

        Algorithm steps that say

        @@ -20793,7 +20789,7 @@

        Runtime Semantics: Evaluation

        1. Let _exprRef_ be the result of evaluating |UnaryExpression|. 1. Let _value_ be ? GetValue(_exprRef_). - 1. Return ? AsyncFunctionAwait(_value_). + 1. Return ? Await(_value_).
        @@ -39301,64 +39297,9 @@

        AsyncFunctionStart ( _promiseCapability_, _asyncFunctionBody_ )

        1. Push _asyncContext_ onto the execution context stack; _asyncContext_ is now the running execution context. 1. Resume the suspended evaluation of _asyncContext_. Let _result_ be the value returned by the resumed computation. 1. Assert: When we return here, _asyncContext_ has already been removed from the execution context stack and _runningContext_ is the currently running execution context. - 1. Assert: _result_ is a normal completion with a value of *undefined*. The possible sources of completion values are AsyncFunctionAwait or, if the async function doesn't await anything, the step 3.g above. - 1. Return. - -
        - - -

        AsyncFunctionAwait ( _value_ )

        - - 1. Let _asyncContext_ be the running execution context. - 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _value_ »). - 1. Let _realm_ be the current Realm Record. - 1. Let _steps_ be the algorithm steps defined in . - 1. Let _onFulfilled_ be CreateBuiltinFunction(_realm_, _steps_, %FunctionPrototype%, « [[AsyncContext]] »). - 1. Let _steps_ be the algorithm steps defined in . - 1. Let _onRejected_ be CreateBuiltinFunction(_realm_, _steps_, %FunctionPrototype%, « [[AsyncContext]] »). - 1. Set _onFulfilled_.[[AsyncContext]] to _asyncContext_. - 1. Set _onRejected_.[[AsyncContext]] to _asyncContext_. - 1. Let _throwawayCapability_ be ! NewPromiseCapability(%Promise%). - 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. - 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). - 1. Remove _asyncContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. - 1. Set the code evaluation state of _asyncContext_ such that when evaluation is resumed with a Completion _resumptionValue_ the following steps will be performed: - 1. Return _resumptionValue_. + 1. Assert: _result_ is a normal completion with a value of *undefined*. The possible sources of completion values are Await or, if the async function doesn't await anything, the step 3.g above. 1. Return. - - The return value of this abstract operation is unused. The interesting return is that of _resumptionValue_ being returned to the |AwaitExpression| that originally called this abstract operation. -
        - - -

        AsyncFunction Awaited Fulfilled

        -

        An AsyncFunction Awaited Fulfilled function is an anonymous built-in function that has an [[AsyncContext]] internal slot. The value of the [[AsyncContext]] internal slot is the execution context that will be restored when the function is called.

        -

        When an AsyncFunction Awaited Fulfilled function _F_ is called with argument _value_, the following steps are taken:

        - - 1. Let _asyncContext_ be _F_.[[AsyncContext]]. - 1. Let _prevContext_ be the running execution context. - 1. Suspend _prevContext_. - 1. Push _asyncContext_ onto the execution context stack; _asyncContext_ is now the running execution context. - 1. Resume the suspended evaluation of _asyncContext_ using NormalCompletion(_value_) as the result of the operation that suspended it. Let _result_ be the value returned by the resumed computation. - 1. Assert: When we reach this step, _asyncContext_ has already been removed from the execution context stack and _prevContext_ is the currently running execution context. - 1. Return Completion(_result_). - -
        - - -

        AsyncFunction Awaited Rejected

        -

        An AsyncFunction Awaited Rejected function is an anonymous built-in function that has an [[AsyncContext]] internal slot. The value of the [[AsyncContext]] internal slot is the execution context that will be restored when the function is called.

        -

        When an AsyncFunction Awaited Rejected function _F_ is called with argument _reason_, the following steps are taken:

        - - 1. Let _asyncContext_ be _F_.[[AsyncContext]]. - 1. Let _prevContext_ be the running execution context. - 1. Suspend _prevContext_. - 1. Push _asyncContext_ onto the execution context stack; _asyncContext_ is now the running execution context. - 1. Resume the suspended evaluation of _asyncContext_ using Completion{[[Type]]: ~throw~, [[Value]]: _reason_, [[Target]]: ~empty~} as the result of the operation that suspended it. Let _result_ be the value returned by the resumed computation. - 1. Assert: When we reach this step, _asyncContext_ has already been removed from the execution context stack and _prevContext_ is the currently running execution context. - 1. Return Completion(_result_). -
        From 62f99214880498842d37a0f302504968bbe2730d Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:39:38 -0500 Subject: [PATCH 05/44] Update GetIterator call sites --- spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index 53e6573418..fea6bba7d2 100644 --- a/spec.html +++ b/spec.html @@ -4978,7 +4978,7 @@

        AsyncIteratorClose ( _iteratorRecord_, _completion_ )

        GetIterator ( _obj_ [ , _hint_ ] [ , _method_ ] )

        -

        The abstract operation GetIterator with argument _obj_ and optional argument _method_ performs the following steps:

        +

        The abstract operation GetIterator with argument _obj_ and optional arguments _hint_ and _method_ performs the following steps:

        1. If _hint_ was not passed, let _hint_ be ~normal~. 1. If _method_ is not present, then @@ -32149,7 +32149,7 @@

        Array.from ( _items_ [ , _mapfn_ [ , _thisArg_ ] ] )

        1. Let _A_ be ? Construct(_C_). 1. Else, 1. Let _A_ be ! ArrayCreate(0). - 1. Let _iteratorRecord_ be ? GetIterator(_items_, _usingIterator_). + 1. Let _iteratorRecord_ be ? GetIterator(_items_, ~normal~, _usingIterator_). 1. Let _k_ be 0. 1. Repeat, 1. If _k_ ≥ 253-1, then @@ -33780,7 +33780,7 @@

        %TypedArray%.from ( _source_ [ , _mapfn_ [ , _thisArg_ ] ] )

        Runtime Semantics: IterableToList( _items_, _method_ )

        The abstract operation IterableToList performs the following steps:

        - 1. Let _iteratorRecord_ be ? GetIterator(_items_, _method_). + 1. Let _iteratorRecord_ be ? GetIterator(_items_, ~normal~, _method_). 1. Let _values_ be a new empty List. 1. Let _next_ be *true*. 1. Repeat, while _next_ is not *false* From f25deb01a4e8cf4859cec578e79f7d53e481ae5f Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:44:11 -0500 Subject: [PATCH 06/44] Fix missed IteratorClose patch --- spec.html | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/spec.html b/spec.html index fea6bba7d2..d85918110a 100644 --- a/spec.html +++ b/spec.html @@ -7584,16 +7584,6 @@

        [[Construct]] ( _argumentsList_, _newTarget_ )

        - -

        AsyncGeneratorFunctionCreate (_kind_, _ParameterList_, _Body_, _Scope_, _Strict_)

        -

        The abstract operation AsyncGeneratorFunctionCreate requires the arguments: _kind_ which is one of (~Normal~, ~Method~), a parameter list production specified by _ParameterList_, a body production specified by _Body_, a Lexical Environment specified by _Scope_, and a Boolean flag _Strict_. AsyncGeneratorFunctionCreate performs the following steps:

        - - 1. Let _functionPrototype_ be the intrinsic object %AsyncGenerator%. - 1. Let _F_ be ! FunctionAllocate(_functionPrototype_, _Strict_, `"generator"`). - 1. Return ! FunctionInitialize(_F_, _kind_, _ParameterList_, _Body_, _Scope_). - -
        -

        FunctionAllocate ( _functionPrototype_, _strict_, _functionKind_ )

        @@ -7664,6 +7654,16 @@

        GeneratorFunctionCreate ( _kind_, _ParameterList_, _Body_, _Scope_, _Strict_ + +

        AsyncGeneratorFunctionCreate (_kind_, _ParameterList_, _Body_, _Scope_, _Strict_)

        +

        The abstract operation AsyncGeneratorFunctionCreate requires the arguments: _kind_ which is one of (~Normal~, ~Method~), a parameter list production specified by _ParameterList_, a body production specified by _Body_, a Lexical Environment specified by _Scope_, and a Boolean flag _Strict_. AsyncGeneratorFunctionCreate performs the following steps:

        + + 1. Let _functionPrototype_ be the intrinsic object %AsyncGenerator%. + 1. Let _F_ be ! FunctionAllocate(_functionPrototype_, _Strict_, `"generator"`). + 1. Return ! FunctionInitialize(_F_, _kind_, _ParameterList_, _Body_, _Scope_). + +
        +

        AddRestrictedFunctionProperties ( _F_, _realm_ )

        @@ -17282,7 +17282,9 @@

        Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, 1. Return Completion(UpdateEmpty(_result_, _V_)). 1. Else, 1. Assert: _iterationKind_ is ~iterate~. - 1. Return ? IteratorClose(_iteratorRecord_, UpdateEmpty(_result_, _V_)). + 1. Let _status_ be UpdateEmpty(_result_, _V_). + 1. If _iteratorKind_ is ~async~, return ? AsyncIteratorClose(_iteratorRecord_, _status_). + 1. Return ? IteratorClose(_iteratorRecord_, _status_). 1. If _result_.[[Value]] is not ~empty~, set _V_ to _result_.[[Value]]. From a595be5ac24f2a9df001fce16b4c6998832f169f Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:47:58 -0500 Subject: [PATCH 07/44] Remove extra wrapper around new common iteration interfaces --- spec.html | 154 ++++++++++++++++++++++++++---------------------------- 1 file changed, 75 insertions(+), 79 deletions(-) diff --git a/spec.html b/spec.html index d85918110a..9ccd01307a 100644 --- a/spec.html +++ b/spec.html @@ -37332,89 +37332,85 @@

        The Iterator Interface

        - -

        Common Iteration Interfaces

        - - -

        The AsyncIterable Interface

        -

        The AsyncIterable interface includes the properties described in :

        - -

        - - - - - - - - - - - - -
        PropertyValueRequirements
        `@@asyncIterator`A function that returns an AsyncIterator object.The returned object must conform to the AsyncIterator interface.
        -
        -
        + +

        The AsyncIterable Interface

        +

        The AsyncIterable interface includes the properties described in :

        + + + + + + + + + + + + + + +
        PropertyValueRequirements
        `@@asyncIterator`A function that returns an AsyncIterator object.The returned object must conform to the AsyncIterator interface.
        +
        +
        - -

        The AsyncIterator Interface

        -

        An object that implements the AsyncIterator interface must include the properties in . Such objects may also implement the properties in .

        - - - - - - - - - - - - + + +
        PropertyValueRequirements
        `next`A function that returns a promise for an IteratorResult object. -

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. If a previous call to the `next` method of an AsyncIterator has returned a promise for an IteratorResult object whose `done` property is *true*, then all subsequent calls to the `next` method of that object should also return a promise for an IteratorResult object whose `done` property is *true*. However, this requirement is not enforced.

        + +

        The AsyncIterator Interface

        +

        An object that implements the AsyncIterator interface must include the properties in . Such objects may also implement the properties in .

        + + + + + + + + + + + + - - -
        PropertyValueRequirements
        `next`A function that returns a promise for an IteratorResult object. +

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. If a previous call to the `next` method of an AsyncIterator has returned a promise for an IteratorResult object whose `done` property is *true*, then all subsequent calls to the `next` method of that object should also return a promise for an IteratorResult object whose `done` property is *true*. However, this requirement is not enforced.

        -

        Additionally, the IteratorResult object that serves as a fulfillment value should have a `value` property whose value is not a promise (or "thenable"). However, this requirement is also not enforced.

        -
        -
        - -

        Arguments may be passed to the next function but their interpretation and validity is dependent upon the target AsyncIterator. The `for`-`await`-`of` statement and other common users of AsyncIterators do not pass any arguments, so AsyncIterator objects that expect to be used in such a manner must be prepared to deal with being called with no arguments.

        -
        - - - - - - - - - - - - + + +
        PropertyValueRequirements
        `return`A function that returns a promise for an IteratorResult object. -

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. Invoking this method notifies the AsyncIterator object that the caller does not intend to make any more `next` method calls to the AsyncIterator. The returned promise will fulfill with an IteratorResult object which will typically have a `done` property whose value is *true*, and a `value` property with the value passed as the argument of the `return` method. However, this requirement is not enforced.

        +

        Additionally, the IteratorResult object that serves as a fulfillment value should have a `value` property whose value is not a promise (or "thenable"). However, this requirement is also not enforced.

        +
        +
        + +

        Arguments may be passed to the next function but their interpretation and validity is dependent upon the target AsyncIterator. The `for`-`await`-`of` statement and other common users of AsyncIterators do not pass any arguments, so AsyncIterator objects that expect to be used in such a manner must be prepared to deal with being called with no arguments.

        +
        + + + + + + + + + + + + - - - - - + + + + + - - -
        PropertyValueRequirements
        `return`A function that returns a promise for an IteratorResult object. +

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. Invoking this method notifies the AsyncIterator object that the caller does not intend to make any more `next` method calls to the AsyncIterator. The returned promise will fulfill with an IteratorResult object which will typically have a `done` property whose value is *true*, and a `value` property with the value passed as the argument of the `return` method. However, this requirement is not enforced.

        -

        Additionally, the IteratorResult object that serves as a fulfillment value should have a `value` property whose value is not a promise (or "thenable"). If the argument value is used in the typical manner, then if it is a rejected promise, a promise rejected with the same reason should be returned; if it is a fulfilled promise, then its fulfillment value should be used as the `value` property of the returned promise's IteratorResult object fulfillment value. However, these requirements are also not enforced.

        -
        `throw`A function that returns a promise for an IteratorResult object. -

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. Invoking this method notifies the AsyncIterator object that the caller has detected an error condition. The argument may be used to identify the error condition and typically will be an exception object. A typical response is to return a rejected promise which rejects with the value passed as the argument.

        +

        Additionally, the IteratorResult object that serves as a fulfillment value should have a `value` property whose value is not a promise (or "thenable"). If the argument value is used in the typical manner, then if it is a rejected promise, a promise rejected with the same reason should be returned; if it is a fulfilled promise, then its fulfillment value should be used as the `value` property of the returned promise's IteratorResult object fulfillment value. However, these requirements are also not enforced.

        +
        `throw`A function that returns a promise for an IteratorResult object. +

        The returned promise, when fulfilled, must fulfill with an object which conforms to the IteratorResult interface. Invoking this method notifies the AsyncIterator object that the caller has detected an error condition. The argument may be used to identify the error condition and typically will be an exception object. A typical response is to return a rejected promise which rejects with the value passed as the argument.

        -

        If the returned promise is fulfilled, the IteratorResult fulfillment value will typically have a `done` property whose value is *true*. Additionally, it should have a `value` property whose value is not a promise (or "thenable"), but this requirement is not enforced.

        -
        -
        - -

        Typically callers of these methods should check for their existence before invoking them. Certain ECMAScript language features including `for`-`await`-`of` and `yield*` call these methods after performing an existence check.

        -
        -
        +

        If the returned promise is fulfilled, the IteratorResult fulfillment value will typically have a `done` property whose value is *true*. Additionally, it should have a `value` property whose value is not a promise (or "thenable"), but this requirement is not enforced.

        +
        +
        + +

        Typically callers of these methods should check for their existence before invoking them. Certain ECMAScript language features including `for`-`await`-`of` and `yield*` call these methods after performing an existence check.

        +
        From 0b9936140f441c50a40fff474d384b63d3541787 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:49:59 -0500 Subject: [PATCH 08/44] Fix wrong heading --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 9ccd01307a..a35a77353a 100644 --- a/spec.html +++ b/spec.html @@ -37770,7 +37770,7 @@

        prototype

        -

        Generator Objects

        +

        AsyncGeneratorFunction Objects

        AsyncGenerator Function objects are functions that are usually created by evaluating |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, and |AsyncGeneratorMethod| syntactic productions. They may also be created by calling the %AsyncGeneratorFunction% intrinsic.

        From 96cbba7172ca7745675673f42c189e0e6bb00248 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:50:45 -0500 Subject: [PATCH 09/44] Fix misplaced well-known symbol --- spec.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec.html b/spec.html index a35a77353a..cff2ebc410 100644 --- a/spec.html +++ b/spec.html @@ -982,17 +982,6 @@

        Well-Known Symbols

        - - - - - + + + + +
        - @@asyncIterator - - `"Symbol.asyncIterator"` - - A method that returns the default AsyncIterator for an object. Called by the semantics of the `for`-`await`-`of` statement. -
        Specification Name @@ -1004,6 +993,17 @@

        Well-Known Symbols

        Value and Purpose
        + @@asyncIterator + + `"Symbol.asyncIterator"` + + A method that returns the default AsyncIterator for an object. Called by the semantics of the `for`-`await`-`of` statement. +
        @@hasInstance From 5343371a24db98af3aac1ff3291398802533cd71 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:53:18 -0500 Subject: [PATCH 10/44] Move AsyncIteratorClose after IteratorClose There seems to be no demand for alphabetization, so let's go for what makes some sense --- spec.html | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/spec.html b/spec.html index cff2ebc410..4657c9c521 100644 --- a/spec.html +++ b/spec.html @@ -4957,24 +4957,6 @@

        CopyDataProperties (_target_, _source_, _excludedItems_)

        Operations on Iterator Objects

        See Common Iteration Interfaces ().

        - -

        AsyncIteratorClose ( _iteratorRecord_, _completion_ )

        -

        The abstract operation AsyncIteratorClose with arguments _iteratorRecord_ and _completion_ is used to notify an async iterator that it should perform any actions it would normally perform when it has reached its completed state:

        - - 1. Assert: Type(_iteratorRecord_.[[Iterator]]) is Object. - 1. Assert: _completion_ is a Completion Record. - 1. Let _iterator_ be _iteratorRecord_.[[Iterator]]. - 1. Let _return_ be ? GetMethod(_iterator_, `"return"`). - 1. If _return_ is *undefined*, return Completion(_completion_). - 1. Let _innerResult_ be Call(_return_, _iterator_, « »). - 1. If _innerResult_.[[Type]] is ~normal~, set _innerResult_ to Await(_innerResult_.[[Value]]). - 1. If _completion_.[[Type]] is ~throw~, return Completion(_completion_). - 1. If _innerResult_.[[Type]] is ~throw~, return Completion(_innerResult_). - 1. If Type(_innerResult_.[[Value]]) is not Object, throw a *TypeError* exception. - 1. Return Completion(_completion_). - -
        -

        GetIterator ( _obj_ [ , _hint_ ] [ , _method_ ] )

        @@ -5061,6 +5043,24 @@

        IteratorClose ( _iteratorRecord_, _completion_ )

        + +

        AsyncIteratorClose ( _iteratorRecord_, _completion_ )

        +

        The abstract operation AsyncIteratorClose with arguments _iteratorRecord_ and _completion_ is used to notify an async iterator that it should perform any actions it would normally perform when it has reached its completed state:

        + + 1. Assert: Type(_iteratorRecord_.[[Iterator]]) is Object. + 1. Assert: _completion_ is a Completion Record. + 1. Let _iterator_ be _iteratorRecord_.[[Iterator]]. + 1. Let _return_ be ? GetMethod(_iterator_, `"return"`). + 1. If _return_ is *undefined*, return Completion(_completion_). + 1. Let _innerResult_ be Call(_return_, _iterator_, « »). + 1. If _innerResult_.[[Type]] is ~normal~, set _innerResult_ to Await(_innerResult_.[[Value]]). + 1. If _completion_.[[Type]] is ~throw~, return Completion(_completion_). + 1. If _innerResult_.[[Type]] is ~throw~, return Completion(_innerResult_). + 1. If Type(_innerResult_.[[Value]]) is not Object, throw a *TypeError* exception. + 1. Return Completion(_completion_). + +
        +

        CreateIterResultObject ( _value_, _done_ )

        From cbfa1085904c7421b4766f2f31aa81b1edd2d0c5 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:55:59 -0500 Subject: [PATCH 11/44] Add missing change to intro of ForIn/OfHeadEvaluation --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 4657c9c521..8e3c761183 100644 --- a/spec.html +++ b/spec.html @@ -17194,7 +17194,7 @@

        Runtime Semantics: LabelledEvaluation

        Runtime Semantics: ForIn/OfHeadEvaluation ( _TDZnames_, _expr_, _iterationKind_ )

        -

        The abstract operation ForIn/OfHeadEvaluation is called with arguments _TDZnames_, _expr_, and _iterationKind_. The value of _iterationKind_ is either ~enumerate~ or ~iterate~.

        +

        The abstract operation ForIn/OfHeadEvaluation is called with arguments _TDZnames_, _expr_, and _iterationKind_. The value of _iterationKind_ is either ~enumerate~, ~iterate~, or ~async-iterate~.

        1. Let _oldEnv_ be the running execution context's LexicalEnvironment. 1. If _TDZnames_ is not an empty List, then From 5a9326fd2c61c003cd0674b65f6a2fa7c00e6994 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:57:54 -0500 Subject: [PATCH 12/44] Move Symbol.asyncIterator This section *does* seem to be alphabetized --- spec.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec.html b/spec.html index 8e3c761183..7c9d811f80 100644 --- a/spec.html +++ b/spec.html @@ -25688,6 +25688,12 @@

        Symbol.for ( _key_ )

        + +

        Symbol.asyncIterator

        +

        The initial value of `Symbol.asyncIterator` is the well known symbol @@asyncIterator ().

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

        +
        +

        Symbol.hasInstance

        @@ -25709,12 +25715,6 @@

        Symbol.iterator

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

        - -

        Symbol.asyncIterator

        -

        The initial value of `Symbol.asyncIterator` is the well known symbol @@asyncIterator ().

        -

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

        -
        -

        Symbol.keyFor ( _sym_ )

        From 9da5f0bd380e88d189c14a26183a872ea40afb9d Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 16:59:15 -0500 Subject: [PATCH 13/44] Move Iteration control abstraction objects into that section --- spec.html | 310 +++++++++++++++++++++++++++--------------------------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/spec.html b/spec.html index 7c9d811f80..5a17d09141 100644 --- a/spec.html +++ b/spec.html @@ -37479,183 +37479,183 @@

        %IteratorPrototype% [ @@iterator ] ( )

        The value of the `name` property of this function is `"[Symbol.iterator]"`.

        - - - -

        The %AsyncIteratorPrototype% Object

        -

        The value of the [[Prototype]] internal slot of the %AsyncIteratorPrototype% object is the intrinsic object %ObjectPrototype%. The %AsyncIteratorPrototype% object is an ordinary object. The initial value of the [[Extensible]] internal slot of the %AsyncIteratorPrototype% object is *true*.

        - -

        All objects defined in this specification that implement the AsyncIterator interface also inherit from %AsyncIteratorPrototype%. ECMAScript code may also define objects that inherit from %AsyncIteratorPrototype%.The %AsyncIteratorPrototype% object provides a place where additional methods that are applicable to all async iterator objects may be added.

        -
        - - -

        %AsyncIteratorPrototype% [ @@asyncIterator ] ( )

        -

        The following steps are taken:

        - - 1. Return the *this* value. - -

        The value of the `name` property of this function is `"[Symbol.asyncIterator]"`.

        -
        -
        - - -

        Async-from-Sync Iterator Objects

        -

        An Async-from-Sync Iterator object is an async iterator that adapts a specific synchronous iterator. There is not a named constructor for Async-from-Sync Iterator objects. Instead, Async-from-Sync iterator objects are created by the CreateAsyncFromSyncIterator abstract operation as needed.

        - -

        CreateAsyncFromSyncIterator(_syncIteratorRecord_) Abstract Operation

        -

        The abstract operation CreateAsyncFromSyncIterator is used to create an async iterator Record from a synchronous iterator Record. It performs the following steps:

        - - 1. Let _asyncIterator_ be ! ObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »). - 1. Set _asyncIterator_.[[SyncIteratorRecord]] to _syncIteratorRecord_. - 1. Return ? GetIterator(_asyncIterator_, ~async~). - -
        - - -

        The %AsyncFromSyncIteratorPrototype% Object

        -

        All Async-from-Sync Iterator Objects inherit properties from the %AsyncFromSyncIteratorPrototype% intrinsic object. The %AsyncFromSyncIteratorPrototype% object is an ordinary object and its [[Prototype]] internal slot is the %AsyncIteratorPrototype% intrinsic object. In addition, %AsyncFromSyncIteratorPrototype% has the following properties:

        + +

        The %AsyncIteratorPrototype% Object

        +

        The value of the [[Prototype]] internal slot of the %AsyncIteratorPrototype% object is the intrinsic object %ObjectPrototype%. The %AsyncIteratorPrototype% object is an ordinary object. The initial value of the [[Extensible]] internal slot of the %AsyncIteratorPrototype% object is *true*.

        + +

        All objects defined in this specification that implement the AsyncIterator interface also inherit from %AsyncIteratorPrototype%. ECMAScript code may also define objects that inherit from %AsyncIteratorPrototype%.The %AsyncIteratorPrototype% object provides a place where additional methods that are applicable to all async iterator objects may be added.

        +
        - -

        %AsyncFromSyncIteratorPrototype%.next ( _value_ )

        + +

        %AsyncIteratorPrototype% [ @@asyncIterator ] ( )

        +

        The following steps are taken:

        - 1. Let _O_ be the *this* value. - 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _badIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). - 1. Return _promiseCapability_.[[Promise]]. - 1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]]. - 1. Let _nextResult_ be IteratorNext(_syncIteratorRecord_, _value_). - 1. IfAbruptRejectPromise(_nextResult_, _promiseCapability_). - 1. Let _nextDone_ be IteratorComplete(_nextResult_). - 1. IfAbruptRejectPromise(_nextDone_, _promiseCapability_). - 1. Let _nextValue_ be IteratorValue(_nextResult_). - 1. IfAbruptRejectPromise(_nextValue_, _promiseCapability_). - 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). - 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _nextValue_ »). - 1. Let _onFulfilled_ be a new built-in function object as defined in . - 1. Set _onFulfilled_.[[Done]] to _nextDone_. - 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). - 1. Return _promiseCapability_.[[Promise]]. + 1. Return the *this* value. +

        The value of the `name` property of this function is `"[Symbol.asyncIterator]"`.

        +
        - -

        %AsyncFromSyncIteratorPrototype%.return ( _value_ )

        + +

        Async-from-Sync Iterator Objects

        +

        An Async-from-Sync Iterator object is an async iterator that adapts a specific synchronous iterator. There is not a named constructor for Async-from-Sync Iterator objects. Instead, Async-from-Sync iterator objects are created by the CreateAsyncFromSyncIterator abstract operation as needed.

        + +

        CreateAsyncFromSyncIterator(_syncIteratorRecord_) Abstract Operation

        +

        The abstract operation CreateAsyncFromSyncIterator is used to create an async iterator Record from a synchronous iterator Record. It performs the following steps:

        - 1. Let _O_ be the *this* value. - 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _badIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). - 1. Return _promiseCapability_.[[Promise]]. - 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. - 1. Let _return_ be GetMethod(_syncIterator_, `"return"`). - 1. IfAbruptRejectPromise(_return_, _promiseCapability_). - 1. If _return_ is *undefined*, then - 1. Let _iterResult_ be ! CreateIterResultObject(_value_, *true*). - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _iterResult_ »). - 1. Return _promiseCapability_.[[Promise]]. - 1. Let _returnResult_ be Call(_return_, _syncIterator_, « _value_ »). - 1. IfAbruptRejectPromise(_returnResult_, _promiseCapability_). - 1. If Type(_returnResult_) is not *Object*, - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). - 1. Return _promiseCapability_.[[Promise]]. - 1. Let _returnDone_ be IteratorComplete(_returnResult_). - 1. IfAbruptRejectPromise(_returnDone_, _promiseCapability_). - 1. Let _returnValue_ be IteratorValue(_returnResult_). - 1. IfAbruptRejectPromise(_returnValue_, _promiseCapability_). - 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). - 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _returnValue_ »). - 1. Let _onFulfilled_ be a new built-in function object as defined in . - 1. Set _onFulfilled_.[[Done]] to _returnDone_. - 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). - 1. Return _promiseCapability_.[[Promise]]. + 1. Let _asyncIterator_ be ! ObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »). + 1. Set _asyncIterator_.[[SyncIteratorRecord]] to _syncIteratorRecord_. + 1. Return ? GetIterator(_asyncIterator_, ~async~).
        - -

        %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

        + +

        The %AsyncFromSyncIteratorPrototype% Object

        +

        All Async-from-Sync Iterator Objects inherit properties from the %AsyncFromSyncIteratorPrototype% intrinsic object. The %AsyncFromSyncIteratorPrototype% object is an ordinary object and its [[Prototype]] internal slot is the %AsyncIteratorPrototype% intrinsic object. In addition, %AsyncFromSyncIteratorPrototype% has the following properties:

        - - 1. Let _O_ be the *this* value. - 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _badIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + +

        %AsyncFromSyncIteratorPrototype%.next ( _value_ )

        + + 1. Let _O_ be the *this* value. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then + 1. Let _badIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]]. + 1. Let _nextResult_ be IteratorNext(_syncIteratorRecord_, _value_). + 1. IfAbruptRejectPromise(_nextResult_, _promiseCapability_). + 1. Let _nextDone_ be IteratorComplete(_nextResult_). + 1. IfAbruptRejectPromise(_nextDone_, _promiseCapability_). + 1. Let _nextValue_ be IteratorValue(_nextResult_). + 1. IfAbruptRejectPromise(_nextValue_, _promiseCapability_). + 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). + 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _nextValue_ »). + 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Set _onFulfilled_.[[Done]] to _nextDone_. + 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). 1. Return _promiseCapability_.[[Promise]]. - 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. - 1. Let _throw_ be GetMethod(_syncIterator_, `"throw"`). - 1. IfAbruptRejectPromise(_throw_, _promiseCapability_). - 1. If _throw_ is *undefined*, then - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _value_ »). + +
        + + +

        %AsyncFromSyncIteratorPrototype%.return ( _value_ )

        + + + 1. Let _O_ be the *this* value. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then + 1. Let _badIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. + 1. Let _return_ be GetMethod(_syncIterator_, `"return"`). + 1. IfAbruptRejectPromise(_return_, _promiseCapability_). + 1. If _return_ is *undefined*, then + 1. Let _iterResult_ be ! CreateIterResultObject(_value_, *true*). + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _iterResult_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _returnResult_ be Call(_return_, _syncIterator_, « _value_ »). + 1. IfAbruptRejectPromise(_returnResult_, _promiseCapability_). + 1. If Type(_returnResult_) is not *Object*, + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _returnDone_ be IteratorComplete(_returnResult_). + 1. IfAbruptRejectPromise(_returnDone_, _promiseCapability_). + 1. Let _returnValue_ be IteratorValue(_returnResult_). + 1. IfAbruptRejectPromise(_returnValue_, _promiseCapability_). + 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). + 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _returnValue_ »). + 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Set _onFulfilled_.[[Done]] to _returnDone_. + 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). 1. Return _promiseCapability_.[[Promise]]. - 1. Let _throwResult_ be Call(_throw_, _syncIterator_, « _value_ »). - 1. IfAbruptRejectPromise(_throwResult_, _promiseCapability_). - 1. If Type(_throwResult_) is not *Object*, - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). + +
        + + +

        %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

        + + + 1. Let _O_ be the *this* value. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then + 1. Let _badIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. + 1. Let _throw_ be GetMethod(_syncIterator_, `"throw"`). + 1. IfAbruptRejectPromise(_throw_, _promiseCapability_). + 1. If _throw_ is *undefined*, then + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _value_ »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _throwResult_ be Call(_throw_, _syncIterator_, « _value_ »). + 1. IfAbruptRejectPromise(_throwResult_, _promiseCapability_). + 1. If Type(_throwResult_) is not *Object*, + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). + 1. Return _promiseCapability_.[[Promise]]. + 1. Let _throwDone_ be IteratorComplete(_throwResult_). + 1. IfAbruptRejectPromise(_throwDone_, _promiseCapability_). + 1. Let _throwValue_ be IteratorValue(_throwResult_). + 1. IfAbruptRejectPromise(_throwValue_, _promiseCapability_). + 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). + 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _throwValue_ »). + 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Set _onFulfilled_.[[Done]] to _throwDone_. + 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). 1. Return _promiseCapability_.[[Promise]]. - 1. Let _throwDone_ be IteratorComplete(_throwResult_). - 1. IfAbruptRejectPromise(_throwDone_, _promiseCapability_). - 1. Let _throwValue_ be IteratorValue(_throwResult_). - 1. IfAbruptRejectPromise(_throwValue_, _promiseCapability_). - 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). - 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _throwValue_ »). - 1. Let _onFulfilled_ be a new built-in function object as defined in . - 1. Set _onFulfilled_.[[Done]] to _throwDone_. - 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). - 1. Return _promiseCapability_.[[Promise]]. - -
        +
        +
        - -

        %AsyncFromSyncIteratorPrototype% [ @@toStringTag ]

        -

        The initial value of the @@toStringTag property is the String value `"Async-from-Sync Iterator"`.

        -

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        -
        + +

        %AsyncFromSyncIteratorPrototype% [ @@toStringTag ]

        +

        The initial value of the @@toStringTag property is the String value `"Async-from-Sync Iterator"`.

        +

        This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

        +
        - -

        Async-from-Sync Iterator Value Unwrap Functions

        + +

        Async-from-Sync Iterator Value Unwrap Functions

        -

        An async-from-sync iterator value unwrap function is an anonymous built-in function that is used by methods of %AsyncFromSyncIteratorPrototype% when processing the `value` field of an IteratorResult object, in order to wait for its value if it is a promise and re-package the result in a new "unwrapped" IteratorResult object. Each async iterator value unwrap function has a [[Done]] internal slot.

        +

        An async-from-sync iterator value unwrap function is an anonymous built-in function that is used by methods of %AsyncFromSyncIteratorPrototype% when processing the `value` field of an IteratorResult object, in order to wait for its value if it is a promise and re-package the result in a new "unwrapped" IteratorResult object. Each async iterator value unwrap function has a [[Done]] internal slot.

        -

        When an async-from-sync iterator value unwrap function _F_ is called with argument _value_, the following steps are taken:

        +

        When an async-from-sync iterator value unwrap function _F_ is called with argument _value_, the following steps are taken:

        - - 1. Return ! CreateIterResultObject(_value_, _F_.[[Done]]). - + + 1. Return ! CreateIterResultObject(_value_, _F_.[[Done]]). + +
        -
        - -

        Properties of Async-from-Sync Iterator Instances

        -

        Async-from-Sync Iterator instances are ordinary objects that inherit properties from the %AsyncFromSyncIteratorPrototype% intrinsic object. Async-from-Sync Iterator instances are initially created with the internal slots listed in .

        - - - - - - - - - - - - - - -
        - Internal Slot - - Description -
        - [[SyncIteratorRecord]] - - A Record, of the type returned by GetIterator, representing the original synchronous iterator which is being adapted. -
        -
        + +

        Properties of Async-from-Sync Iterator Instances

        +

        Async-from-Sync Iterator instances are ordinary objects that inherit properties from the %AsyncFromSyncIteratorPrototype% intrinsic object. Async-from-Sync Iterator instances are initially created with the internal slots listed in .

        + + + + + + + + + + + + + + +
        + Internal Slot + + Description +
        + [[SyncIteratorRecord]] + + A Record, of the type returned by GetIterator, representing the original synchronous iterator which is being adapted. +
        +
        +
        From c6d3c24f1eb8ef2427969e9842c9603acea5868b Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 17:03:31 -0500 Subject: [PATCH 14/44] Another small fix for AsyncGeneratorFunction section --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 5a17d09141..5babda643a 100644 --- a/spec.html +++ b/spec.html @@ -37771,7 +37771,7 @@

        prototype

        AsyncGeneratorFunction Objects

        -

        AsyncGenerator Function objects are functions that are usually created by evaluating |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, and |AsyncGeneratorMethod| syntactic productions. They may also be created by calling the %AsyncGeneratorFunction% intrinsic.

        +

        AsyncGeneratorFunction objects are functions that are usually created by evaluating |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, and |AsyncGeneratorMethod| syntactic productions. They may also be created by calling the %AsyncGeneratorFunction% intrinsic.

        The AsyncGeneratorFunction Constructor

        From ef1435cf68b524351ac6a6df93968aaceedced68 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 12 Jan 2018 17:27:50 -0500 Subject: [PATCH 15/44] Apply "Miscellaneous Patches" everywhere --- spec.html | 74 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/spec.html b/spec.html index 5babda643a..b2cb0b327b 100644 --- a/spec.html +++ b/spec.html @@ -5663,8 +5663,8 @@

        GetSuperBase ( )

        Global Environment Records

        A global Environment Record is used to represent the outer most scope that is shared by all of the ECMAScript |Script| elements that are processed in a common realm. A global Environment Record provides the bindings for built-in globals (clause ), properties of the global object, and for all top-level declarations (, ) that occur within a |Script|.

        -

        A global Environment Record is logically a single record but it is specified as a composite encapsulating an object Environment Record and a declarative Environment Record. The object Environment Record has as its base object the global object of the associated Realm Record. This global object is the value returned by the global Environment Record's GetThisBinding concrete method. The object Environment Record component of a global Environment Record contains the bindings for all built-in globals (clause ) and all bindings introduced by a |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration| or |VariableStatement| contained in global code. The bindings for all other ECMAScript declarations in global code are contained in the declarative Environment Record component of the global Environment Record.

        -

        Properties may be created directly on a global object. Hence, the object Environment Record component of a global Environment Record may contain both bindings created explicitly by |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, or |VariableDeclaration| declarations and bindings created implicitly as properties of the global object. In order to identify which bindings were explicitly created using declarations, a global Environment Record maintains a list of the names bound using its CreateGlobalVarBinding and CreateGlobalFunctionBinding concrete methods.

        +

        A global Environment Record is logically a single record but it is specified as a composite encapsulating an object Environment Record and a declarative Environment Record. The object Environment Record has as its base object the global object of the associated Realm Record. This global object is the value returned by the global Environment Record's GetThisBinding concrete method. The object Environment Record component of a global Environment Record contains the bindings for all built-in globals (clause ) and all bindings introduced by a |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, or |VariableStatement| contained in global code. The bindings for all other ECMAScript declarations in global code are contained in the declarative Environment Record component of the global Environment Record.

        +

        Properties may be created directly on a global object. Hence, the object Environment Record component of a global Environment Record may contain both bindings created explicitly by |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, or |VariableDeclaration| declarations and bindings created implicitly as properties of the global object. In order to identify which bindings were explicitly created using declarations, a global Environment Record maintains a list of the names bound using its CreateGlobalVarBinding and CreateGlobalFunctionBinding concrete methods.

        Global Environment Records have the additional fields listed in and the additional methods listed in .

        @@ -5688,7 +5688,7 @@

        Global Environment Records

        Object Environment Record @@ -5710,7 +5710,7 @@

        Global Environment Records

        Declarative Environment Record @@ -5721,7 +5721,7 @@

        Global Environment Records

        List of String @@ -5751,7 +5751,7 @@

        Global Environment Records

        HasVarDeclaration (N) @@ -7776,7 +7776,7 @@

        FunctionDeclarationInstantiation ( _func_, _argumentsList_ )

        1. Let _functionsToInitialize_ be a new empty List. 1. For each _d_ in _varDeclarations_, in reverse list order, do 1. If _d_ is neither a |VariableDeclaration| nor a |ForBinding| nor a |BindingIdentifier|, then - 1. Assert: _d_ is either a |FunctionDeclaration|, a |GeneratorDeclaration|, or an |AsyncFunctionDeclaration|. + 1. Assert: _d_ is either a |FunctionDeclaration|, a |GeneratorDeclaration|, an |AsyncFunctionDeclaration|, or an |AsyncGeneratorDeclaration|. 1. Let _fn_ be the sole element of the BoundNames of _d_. 1. If _fn_ is not an element of _functionNames_, then 1. Insert _fn_ as the first element of _functionNames_. @@ -9580,20 +9580,20 @@

        Types of Source Code

        There are four types of ECMAScript code:

        • - Global code is source text that is treated as an ECMAScript |Script|. The global code of a particular |Script| does not include any source text that is parsed as part of a |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |MethodDefinition|, |ArrowFunction|, |AsyncArrowFunction|, |ClassDeclaration|, or |ClassExpression|. + Global code is source text that is treated as an ECMAScript |Script|. The global code of a particular |Script| does not include any source text that is parsed as part of a |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, |MethodDefinition|, |ArrowFunction|, |AsyncArrowFunction|, |ClassDeclaration|, or |ClassExpression|.
        • Eval code is the source text supplied to the built-in `eval` function. More precisely, if the parameter to the built-in `eval` function is a String, it is treated as an ECMAScript |Script|. The eval code for a particular invocation of `eval` is the global code portion of that |Script|.
        • - Function code is source text that is parsed to supply the value of the [[ECMAScriptCode]] and [[FormalParameters]] internal slots (see ) of an ECMAScript function object. The function code of a particular ECMAScript function does not include any source text that is parsed as the function code of a nested |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |MethodDefinition|, |ArrowFunction|, |AsyncArrowFunction|, |ClassDeclaration|, or |ClassExpression|. + Function code is source text that is parsed to supply the value of the [[ECMAScriptCode]] and [[FormalParameters]] internal slots (see ) of an ECMAScript function object. The function code of a particular ECMAScript function does not include any source text that is parsed as the function code of a nested |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, |MethodDefinition|, |ArrowFunction|, |AsyncArrowFunction|, |ClassDeclaration|, or |ClassExpression|.
        • - Module code is source text that is code that is provided as a |ModuleBody|. It is the code that is directly evaluated when a module is initialized. The module code of a particular module does not include any source text that is parsed as part of a nested |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |MethodDefinition|, |ArrowFunction|, |AsyncArrowFunction|, |ClassDeclaration|, or |ClassExpression|. + Module code is source text that is code that is provided as a |ModuleBody|. It is the code that is directly evaluated when a module is initialized. The module code of a particular module does not include any source text that is parsed as part of a nested |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, |MethodDefinition|, |ArrowFunction|, |AsyncArrowFunction|, |ClassDeclaration|, or |ClassExpression|.
        -

        Function code is generally provided as the bodies of Function Definitions (), Arrow Function Definitions (), Method Definitions (), Generator Definitions (), Async Function Definitions (), and Async Arrow Functions (). Function code is also derived from the arguments to the `Function` constructor (), the `GeneratorFunction` constructor (), and the `AsyncFunction` constructor ().

        +

        Function code is generally provided as the bodies of Function Definitions (), Arrow Function Definitions (), Method Definitions (), Generator Function Definitions (), Async Function Definitions (), Async Generator Function Definitions (), and Async Arrow Functions (). Function code is also derived from the arguments to the `Function` constructor (), the `GeneratorFunction` constructor (), and the `AsyncFunction` constructor ().

        @@ -9614,10 +9614,10 @@

        Strict Mode Code

        Eval code is strict mode code if it begins with a Directive Prologue that contains a Use Strict Directive or if the call to `eval` is a direct eval that is contained in strict mode code.
      • - Function code is strict mode code if the associated |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |MethodDefinition|, |ArrowFunction|, or |AsyncArrowFunction| is contained in strict mode code or if the code that produces the value of the function's [[ECMAScriptCode]] internal slot begins with a Directive Prologue that contains a Use Strict Directive. + Function code is strict mode code if the associated |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, |MethodDefinition|, |ArrowFunction|, or |AsyncArrowFunction| is contained in strict mode code or if the code that produces the value of the function's [[ECMAScriptCode]] internal slot begins with a Directive Prologue that contains a Use Strict Directive.
      • - Function code that is supplied as the arguments to the built-in `Function`, `Generator`, and `AsyncFunction` constructors is strict mode code if the last argument is a String that when processed is a |FunctionBody| that begins with a Directive Prologue that contains a Use Strict Directive. + Function code that is supplied as the arguments to the built-in `Function`, `Generator`, `AsyncFunction`, and `AsyncGenerator` constructors is strict mode code if the last argument is a String that when processed is a |FunctionBody| that begins with a Directive Prologue that contains a Use Strict Directive.
      • ECMAScript code that is not strict mode code is called non-strict code.

        @@ -11548,6 +11548,7 @@

        Syntax

        ClassExpression[?Yield, ?Await] GeneratorExpression AsyncFunctionExpression + AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral[?Yield, ?Await, ~Tagged] CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] #parencover @@ -11639,6 +11640,7 @@

        Static Semantics: IsIdentifierRef

        ClassExpression GeneratorExpression AsyncFunctionExpression + AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral CoverParenthesizedExpressionAndArrowParameterList @@ -11662,6 +11664,7 @@

        Static Semantics: IsValidSimpleAssignmentTarget

        ClassExpression GeneratorExpression AsyncFunctionExpression + AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral @@ -12119,6 +12122,7 @@

        Function Defining Expressions

        See for PrimaryExpression : GeneratorExpression.

        See for PrimaryExpression : ClassExpression.

        See for PrimaryExpression : AsyncFunctionExpression.

        +

        See for PrimaryExpression : AsyncGeneratorExpression.

        @@ -15038,6 +15042,10 @@

        Static Semantics: DeclarationPart

        1. Return |AsyncFunctionDeclaration|. + HoistableDeclaration : AsyncGeneratorDeclaration + + 1. Return |AsyncGeneratorDeclaration|. + Declaration : ClassDeclaration 1. Return |ClassDeclaration|. @@ -15118,13 +15126,10 @@

        Runtime Semantics: LabelledEvaluation

        Runtime Semantics: Evaluation

        - HoistableDeclaration : GeneratorDeclaration - - - 1. Return NormalCompletion(~empty~). - - - HoistableDeclaration : AsyncFunctionDeclaration + HoistableDeclaration : + GeneratorDeclaration + AsyncFunctionDeclaration + AsyncGeneratorDeclaration 1. Return NormalCompletion(~empty~). @@ -15498,7 +15503,7 @@

        Runtime Semantics: BlockDeclarationInstantiation( _code_, _env_ )

        1. Perform ! _envRec_.CreateImmutableBinding(_dn_, *true*). 1. Else, 1. Perform ! _envRec_.CreateMutableBinding(_dn_, *false*). - 1. If _d_ is a |FunctionDeclaration|, a |GeneratorDeclaration|, or an |AsyncFunctionDeclaration|, then + 1. If _d_ is a |FunctionDeclaration|, a |GeneratorDeclaration|, an |AsyncFunctionDeclaration|, or an |AsyncGeneratorDeclaration|, then 1. Let _fn_ be the sole element of the BoundNames of _d_. 1. Let _fo_ be the result of performing InstantiateFunctionObject for _d_ with argument _env_. 1. Perform _envRec_.InitializeBinding(_fn_, _fo_). @@ -16266,7 +16271,7 @@

        Syntax

        [lookahead <! {`{`, `function`, `async` [no |LineTerminator| here] `function`, `class`, `let [`}] Expression[+In, ?Yield, ?Await] `;` -

        An |ExpressionStatement| cannot start with a U+007B (LEFT CURLY BRACKET) because that might make it ambiguous with a |Block|. An |ExpressionStatement| cannot start with the `function` or `class` keywords because that would make it ambiguous with a |FunctionDeclaration|, a |GeneratorDeclaration|, or a |ClassDeclaration|. An |ExpressionStatement| cannot start with `async function` because that would make it ambiguous with an |AsyncFunctionDeclaration|. An |ExpressionStatement| cannot start with the two token sequence `let [` because that would make it ambiguous with a `let` |LexicalDeclaration| whose first |LexicalBinding| was an |ArrayBindingPattern|.

        +

        An |ExpressionStatement| cannot start with a U+007B (LEFT CURLY BRACKET) because that might make it ambiguous with a |Block|. An |ExpressionStatement| cannot start with the `function` or `class` keywords because that would make it ambiguous with a |FunctionDeclaration|, a |GeneratorDeclaration|, or a |ClassDeclaration|. An |ExpressionStatement| cannot start with `async function` because that would make it ambiguous with an |AsyncFunctionDeclaration| or a |AsyncGeneratorDeclaration|. An |ExpressionStatement| cannot start with the two token sequence `let [` because that would make it ambiguous with a `let` |LexicalDeclaration| whose first |LexicalBinding| was an |ArrayBindingPattern|.

        @@ -19335,6 +19340,7 @@

        Syntax

        PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, ~Await] `)` `{` FunctionBody[~Yield, ~Await] `}` GeneratorMethod[?Yield, ?Await] AsyncMethod[?Yield, ?Await] + AsyncGeneratorMethod[?Yield, ?Await] `get` PropertyName[?Yield, ?Await] `(` `)` `{` FunctionBody[~Yield, ~Await] `}` `set` PropertyName[?Yield, ?Await] `(` PropertySetParameterList `)` `{` FunctionBody[~Yield, ~Await] `}` @@ -19440,8 +19446,8 @@

        Static Semantics: SpecialMethod

        MethodDefinition : GeneratorMethod - AsyncGeneratorMethod AsyncMethod + AsyncGeneratorMethod `get` PropertyName `(` `)` `{` FunctionBody `}` `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` @@ -20532,12 +20538,12 @@

        Syntax

        `await` is parsed as an |AwaitExpression| when the [Await] parameter is present. The [Await] parameter is present in the following contexts:

        • In an |AsyncFunctionBody|.
        • -
        • In the |FormalParameters| of an |AsyncFunctionDeclaration| and |AsyncFunctionExpression|. |AwaitExpression| in this position is a Syntax error via static semantics.
        • +
        • In the |FormalParameters| of an |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |AsyncGeneratorDeclaration|, or |AsyncGeneratorExpression|. |AwaitExpression| in this position is a Syntax error via static semantics.

        When |Module| is the syntactic goal symbol and the [Await] parameter is absent, `await` is parsed as a keyword and will be a Syntax error. When |Script| is the syntactic goal symbol, `await` may be parsed as an identifier when the [Await] parameter is absent. This includes the following contexts:

          -
        • Anywhere outside of an |AsyncFunctionBody| or |FormalParameters| of an |AsyncFunctionDeclaration| or |AsyncFunctionExpression|.
        • -
        • In the |BindingIdentifier| of a |FunctionExpression| or |GeneratorExpression|.
        • +
        • Anywhere outside of an |AsyncFunctionBody| or |FormalParameters| of an |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |AsyncGeneratorDeclaration|, or |AsyncGeneratorExpression|.
        • +
        • In the |BindingIdentifier| of a |FunctionExpression|, |GeneratorExpression|, or |AsyncGeneratorExpression|.
        @@ -21060,6 +21066,7 @@

        Static Semantics: IsInTailPosition( _call_ )

        1. Let _body_ be the |FunctionBody|, |ConciseBody|, or |AsyncConciseBody| that most closely contains _call_. 1. If _body_ is the |FunctionBody| of a |GeneratorBody|, return *false*. 1. If _body_ is the |FunctionBody| of an |AsyncFunctionBody|, return *false*. + 1. If _body_ is the |FunctionBody| of an |AsyncGeneratorBody|, return *false*. 1. If _body_ is an |AsyncConciseBody|, return *false*. 1. Return the result of HasCallInTailPosition of _body_ with argument _call_.
        @@ -21290,6 +21297,7 @@

        Expression Rules

        ClassExpression GeneratorExpression AsyncFunctionExpression + AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral @@ -21619,7 +21627,7 @@

        Runtime Semantics: GlobalDeclarationInstantiation ( _script_, _env_ )

        1. Let _declaredFunctionNames_ be a new empty List. 1. For each _d_ in _varDeclarations_, in reverse list order, do 1. If _d_ is neither a |VariableDeclaration| nor a |ForBinding| nor a |BindingIdentifier|, then - 1. Assert: _d_ is either a |FunctionDeclaration|, a |GeneratorDeclaration|, or an |AsyncFunctionDeclaration|. + 1. Assert: _d_ is either a |FunctionDeclaration|, a |GeneratorDeclaration|, an |AsyncFunctionDeclaration|, or an |AsyncGeneratorDeclaration|. 1. NOTE: If there are multiple function declarations for the same name, the last declaration is used. 1. Let _fn_ be the sole element of the BoundNames of _d_. 1. If _fn_ is not an element of _declaredFunctionNames_, then @@ -22904,7 +22912,7 @@

        ModuleDeclarationEnvironmentSetup( _module_ )

        1. Perform ! _envRec_.CreateImmutableBinding(_dn_, *true*). 1. Else, 1. Perform ! _envRec_.CreateMutableBinding(_dn_, *false*). - 1. If _d_ is a |FunctionDeclaration|, a |GeneratorDeclaration|, or an |AsyncFunctionDeclaration|, then + 1. If _d_ is a |FunctionDeclaration|, a |GeneratorDeclaration|, an |AsyncFunctionDeclaration|, or an |AsyncGeneratorDeclaration|, then 1. Let _fo_ be the result of performing InstantiateFunctionObject for _d_ with argument _env_. 1. Call _envRec_.InitializeBinding(_dn_, _fo_).
        @@ -23799,7 +23807,7 @@

        Forbidden Extensions

        An implementation must not extend this specification in the following ways:

        • - ECMAScript function objects defined using syntactic constructors in strict mode code must not be created with own properties named `"caller"` or `"arguments"`. Such own properties also must not be created for function objects defined using an |ArrowFunction|, |MethodDefinition|, |GeneratorDeclaration|, |GeneratorExpression|, |ClassDeclaration|, |ClassExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, or |AsyncArrowFunction| regardless of whether the definition is contained in strict mode code. Built-in functions, strict functions created using the `Function` constructor, generator functions created using the `Generator` constructor, async functions created using the `AsyncFunction` constructor, and functions created using the `bind` method also must not be created with such own properties. + ECMAScript function objects defined using syntactic constructors in strict mode code must not be created with own properties named `"caller"` or `"arguments"`. Such own properties also must not be created for function objects defined using an |ArrowFunction|, |MethodDefinition|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, |ClassDeclaration|, |ClassExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, or |AsyncArrowFunction| regardless of whether the definition is contained in strict mode code. Built-in functions, strict functions created using the `Function` constructor, generator functions created using the `Generator` constructor, async functions created using the `AsyncFunction` constructor, and functions created using the `bind` method also must not be created with such own properties.
        • If an implementation extends any function object with an own property named `"caller"` the value of that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function object. If it is an accessor property, the function that is the value of the property's [[Get]] attribute must never return a strict function when called. @@ -24031,7 +24039,7 @@

          Runtime Semantics: EvalDeclarationInstantiation( _body_, _varEnv_, _lexEnv_, 1. Let _declaredFunctionNames_ be a new empty List. 1. For each _d_ in _varDeclarations_, in reverse list order, do 1. If _d_ is neither a |VariableDeclaration| nor a |ForBinding| nor a |BindingIdentifier|, then - 1. Assert: _d_ is either a |FunctionDeclaration|, a |GeneratorDeclaration|, or an |AsyncFunctionDeclaration|. + 1. Assert: _d_ is either a |FunctionDeclaration|, a |GeneratorDeclaration|, an |AsyncFunctionDeclaration|, or an |AsyncGeneratorDeclaration|. 1. NOTE: If there are multiple function declarations for the same name, the last declaration is used. 1. Let _fn_ be the sole element of the BoundNames of _d_. 1. If _fn_ is not an element of _declaredFunctionNames_, then @@ -25220,7 +25228,7 @@

          Function Objects

          The Function Constructor

          The Function constructor is the %Function% intrinsic object and the initial value of the `Function` property of the global object. When `Function` is called as a function rather than as a constructor, it creates and initializes a new function object. Thus the function call `Function(…)` is equivalent to the object creation expression `new Function(…)` with the same arguments.

          -

          The `Function` constructor 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 `Function` behaviour must include a `super` call to the `Function` constructor to create and initialize a subclass instance with the internal slots necessary for built-in function behaviour. All ECMAScript syntactic forms for defining function objects create instances of `Function`. There is no syntactic means to create instances of `Function` subclasses except for the built-in `GeneratorFunction` and `AsyncFunction` subclasses.

          +

          The `Function` constructor 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 `Function` behaviour must include a `super` call to the `Function` constructor to create and initialize a subclass instance with the internal slots necessary for built-in function behaviour. All ECMAScript syntactic forms for defining function objects create instances of `Function`. There is no syntactic means to create instances of `Function` subclasses except for the built-in `GeneratorFunction`, `AsyncFunction`, and `AsyncGeneratorFunction` subclasses.

          @@ -25448,7 +25456,7 @@

          Function.prototype.toString ( )

          `toString` Representation Requirements:

          • - The string representation must have the syntax of a |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |ClassDeclaration|, |ClassExpression|, |ArrowFunction|, |AsyncArrowFunction|, or |MethodDefinition| depending upon the actual characteristics of the object. + The string representation must have the syntax of a |FunctionDeclaration|, |FunctionExpression|, |GeneratorDeclaration|, |GeneratorExpression|, |AsyncFunctionDeclaration|, |AsyncFunctionExpression|, |AsyncGeneratorDeclaration|, |AsyncGeneratorExpression|, |ClassDeclaration|, |ClassExpression|, |ArrowFunction|, |AsyncArrowFunction|, or |MethodDefinition| depending upon the actual characteristics of the object.
          • The use and placement of white space, line terminators, and semicolons within the representation String is implementation-dependent. @@ -25512,7 +25520,7 @@

            prototype

            Function instances that can be used as a constructor have a `prototype` property. Whenever such a Function instance is created another ordinary object is also created and is the initial value of the function's `prototype` property. Unless otherwise specified, the value of the `prototype` property is used to initialize the [[Prototype]] internal slot of the object created when that function is invoked as a constructor.

            This property has the attributes { [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

            -

            Function objects created using `Function.prototype.bind`, or by evaluating a |MethodDefinition| (that is not a |GeneratorMethod|) or an |ArrowFunction| do not have a `prototype` property.

            +

            Function objects created using `Function.prototype.bind`, or by evaluating a |MethodDefinition| (that is not a |GeneratorMethod| or |AsyncGeneratorMethod|) or an |ArrowFunction| do not have a `prototype` property.

            From 25125777503e1fd2cc4bc4db629d30d68d37682f Mon Sep 17 00:00:00 2001 From: Brian Terlson Date: Tue, 13 Feb 2018 14:40:45 -0800 Subject: [PATCH 16/44] Editorial: fix assert missing 'async generator' alternative. --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index b2cb0b327b..acf6de12c3 100644 --- a/spec.html +++ b/spec.html @@ -7590,7 +7590,7 @@

            FunctionAllocate ( _functionPrototype_, _strict_, _functionKind_ )

            The abstract operation FunctionAllocate requires the three arguments _functionPrototype_, _strict_ and _functionKind_. FunctionAllocate performs the following steps:

            1. Assert: Type(_functionPrototype_) is Object. - 1. Assert: _functionKind_ is either `"normal"`, `"non-constructor"`, `"generator"`, or `"async"`. + 1. Assert: _functionKind_ is either `"normal"`, `"non-constructor"`, `"generator"`, `"async"`, or `"async generator"`. 1. If _functionKind_ is `"normal"`, let _needsConstruct_ be *true*. 1. Else, let _needsConstruct_ be *false*. 1. If _functionKind_ is `"non-constructor"`, set _functionKind_ to `"normal"`. From d31a4de58034c0a080cdb10c858f4aec578f2418 Mon Sep 17 00:00:00 2001 From: Brian Terlson Date: Tue, 13 Feb 2018 16:30:51 -0800 Subject: [PATCH 17/44] Editorial: badIteratorError --> invalidIteratorError --- spec.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec.html b/spec.html index acf6de12c3..b4ff6ca47e 100644 --- a/spec.html +++ b/spec.html @@ -37529,8 +37529,8 @@

            %AsyncFromSyncIteratorPrototype%.next ( _value_ )

            1. Let _O_ be the *this* value. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _badIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Let _invalidIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]]. 1. Let _nextResult_ be IteratorNext(_syncIteratorRecord_, _value_). @@ -37555,8 +37555,8 @@

            %AsyncFromSyncIteratorPrototype%.return ( _value_ )

            1. Let _O_ be the *this* value. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _badIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Let _invalidIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. 1. Let _return_ be GetMethod(_syncIterator_, `"return"`). @@ -37590,8 +37590,8 @@

            %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

            1. Let _O_ be the *this* value. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _badIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Let _invalidIteratorError_ be a new *TypeError* exception. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. 1. Let _throw_ be GetMethod(_syncIterator_, `"throw"`). From 3daca01f9ef8463029f90c3630ad57e5cd47291c Mon Sep 17 00:00:00 2001 From: Brian Terlson Date: Tue, 13 Feb 2018 16:46:57 -0800 Subject: [PATCH 18/44] Editorial: use proper optional arg style --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index b4ff6ca47e..5d3c4aa66b 100644 --- a/spec.html +++ b/spec.html @@ -4959,7 +4959,7 @@

            Operations on Iterator Objects

            -

            GetIterator ( _obj_ [ , _hint_ ] [ , _method_ ] )

            +

            GetIterator ( _obj_ [ , _hint_ [ , _method_ ] ] )

            The abstract operation GetIterator with argument _obj_ and optional arguments _hint_ and _method_ performs the following steps:

            1. If _hint_ was not passed, let _hint_ be ~normal~. From ac7ab82727538d0a6ee383502e40ac61adbf5b0a Mon Sep 17 00:00:00 2001 From: Brian Terlson Date: Tue, 13 Feb 2018 16:55:29 -0800 Subject: [PATCH 19/44] Editorial: remove duplicate definition of return statement and out of place note --- spec.html | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spec.html b/spec.html index 5d3c4aa66b..d85392c2ef 100644 --- a/spec.html +++ b/spec.html @@ -14948,14 +14948,7 @@

            Syntax

            BreakableStatement[Yield, Await, Return] : IterationStatement[?Yield, ?Await, ?Return] SwitchStatement[?Yield, ?Await, ?Return] - - ReturnStatement[Yield, Await] : - `return` `;` - `return` [no LineTerminator here] Expression[+In, ?Yield, ?Await] `;` - -

            A `return` statement causes a function to cease execution and return a value to the caller. If |Expression| is omitted, the return value is *undefined*. Otherwise, the return value is the value of |Expression|.

            -
            From a28b90bf17b3bfb2184cc6723a01dc42700c9c4c Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 12:57:57 -0500 Subject: [PATCH 20/44] Editorial: Make AsyncGeneratorDeclaration a HoistableDeclaration ... which is assumed later. Please check that the settings of the grammatical parameters are correct. --- spec.html | 1 + 1 file changed, 1 insertion(+) diff --git a/spec.html b/spec.html index d85392c2ef..f8f5c03265 100644 --- a/spec.html +++ b/spec.html @@ -14944,6 +14944,7 @@

            Syntax

            FunctionDeclaration[?Yield, ?Await, ?Default] GeneratorDeclaration[?Yield, ?Await, ?Default] AsyncFunctionDeclaration[?Yield, ?Await, ?Default] + AsyncGeneratorDeclaration[?Yield, ?Await, ?Default] BreakableStatement[Yield, Await, Return] : IterationStatement[?Yield, ?Await, ?Return] From c40e0daad492562f60dfb2bcc234301283d4f639 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 12:59:15 -0500 Subject: [PATCH 21/44] Editorial: Add "type="definition" to the main new --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index f8f5c03265..7f1902fa85 100644 --- a/spec.html +++ b/spec.html @@ -19875,7 +19875,7 @@

            Runtime Semantics: Evaluation

            Async Generator Function Definitions

            Syntax

            - + AsyncGeneratorMethod[Yield, Await] : `async` [no LineTerminator here] `*` PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, +Await] `)` `{` AsyncGeneratorBody `}` From 038fb17b386a2f0efb3810013f4189420b77dc7d Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 13:01:31 -0500 Subject: [PATCH 22/44] Editorial: add `async` keyword to lots of non-defining productions ... to match defining productions for AsyncGeneratorMethod AsyncGeneratorDeclaration AsyncGeneratorExpression --- spec.html | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/spec.html b/spec.html index 7f1902fa85..5a11925c70 100644 --- a/spec.html +++ b/spec.html @@ -19898,7 +19898,7 @@

            Syntax

            Static Semantics: Early Errors

            - AsyncGeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}`
            • It is a Syntax Error if HasDirectSuper of |AsyncGeneratorMethod| is *true*.
            • It is a Syntax Error if |UniqueFormalParameters| Contains |YieldExpression| is *true*.
            • @@ -19907,11 +19907,11 @@

              Static Semantics: Early Errors

            • It is a Syntax Error if any element of the BoundNames of |UniqueFormalParameters| also occurs in the LexicallyDeclaredNames of |AsyncGeneratorBody|.
            - AsyncGeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - AsyncGeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - AsyncGeneratorDeclaration : `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}`
            • If the source code matching this production is strict mode code, the Early Error rules for UniqueFormalParameters : FormalParameters are applied.
            • @@ -19930,11 +19930,11 @@

              Static Semantics: Early Errors

              Static Semantics: BoundNames

              - AsyncGeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return the BoundNames of |BindingIdentifier|. - AsyncGeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return « `"*default*"` ». @@ -19947,7 +19947,7 @@

              Static Semantics: BoundNames

              Static Semantics: ComputedPropertyContains

              With parameter _symbol_.

              - AsyncGeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. @@ -19958,11 +19958,11 @@

              Static Semantics: Contains

              With parameter _symbol_.

              - AsyncGeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - AsyncGeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - AsyncGeneratorExpression : `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorExpression : `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return *false*. @@ -19975,7 +19975,7 @@

              Static Semantics: Contains

              Static Semantics: HasDirectSuper

              - AsyncGeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` 1. If |UniqueFormalParameters| Contains |SuperCall| is *true*, return *true*. 1. Return |AsyncGeneratorBody| Contains |SuperCall|. @@ -19985,11 +19985,11 @@

              Static Semantics: HasDirectSuper

              Static Semantics: HasName

              - AsyncGeneratorExpression : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorExpression : `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return *false*. - AsyncGeneratorExpression : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorExpression : `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return *true*. @@ -19999,9 +19999,9 @@

              Static Semantics: HasName

              Static Semantics: IsConstantDeclaration

              - AsyncGeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - AsyncGeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorDeclaration : `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return *false*. @@ -20011,7 +20011,7 @@

              Static Semantics: IsConstantDeclaration

              Static Semantics: IsFunctionDefinition

              - AsyncGeneratorExpression : `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorExpression : `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return *true*. @@ -20020,7 +20020,7 @@

              Static Semantics: IsFunctionDefinition

              Static Semantics: PropName

              - AsyncGeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` 1. Return PropName of |PropertyName|. From fe36ba182fce18966bcacafbb432c48311972741 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 13:03:54 -0500 Subject: [PATCH 23/44] Editorial: change AsyncGeneratorDeclaration to AsyncGeneratorExpression ... in one spot. I think that was the intent. --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 5a11925c70..e410790bb5 100644 --- a/spec.html +++ b/spec.html @@ -19911,7 +19911,7 @@

              Static Semantics: Early Errors

              AsyncGeneratorDeclaration : `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - AsyncGeneratorDeclaration : `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorExpression : `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}`
              • If the source code matching this production is strict mode code, the Early Error rules for UniqueFormalParameters : FormalParameters are applied.
              • From 5d1afb3c698144800641911c58529348efb1560a Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 13:05:09 -0500 Subject: [PATCH 24/44] Markup: fix a well-formedness error --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index e410790bb5..cefedc0fd9 100644 --- a/spec.html +++ b/spec.html @@ -38231,8 +38231,8 @@

                AsyncGeneratorResolve ( _generator_, _value_, _done_ )

                1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _iteratorResult_ »). 1. Perform ! AsyncGeneratorResumeNext(_generator_). 1. Return *undefined*. - - + +

                AsyncGeneratorReject ( _generator_, _exception_ )

                From d4ab5dbcc38de4f0bb8c9baac7f9f24fb4639889 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 13:07:07 -0500 Subject: [PATCH 25/44] Editorial: change title of CreateAsyncFromSyncIterator clause ... to the spec's current convention. --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index cefedc0fd9..2ba7fa48c7 100644 --- a/spec.html +++ b/spec.html @@ -37504,7 +37504,7 @@

                Async-from-Sync Iterator Objects

                An Async-from-Sync Iterator object is an async iterator that adapts a specific synchronous iterator. There is not a named constructor for Async-from-Sync Iterator objects. Instead, Async-from-Sync iterator objects are created by the CreateAsyncFromSyncIterator abstract operation as needed.

                -

                CreateAsyncFromSyncIterator(_syncIteratorRecord_) Abstract Operation

                +

                CreateAsyncFromSyncIterator ( _syncIteratorRecord_ )

                The abstract operation CreateAsyncFromSyncIterator is used to create an async iterator Record from a synchronous iterator Record. It performs the following steps:

                1. Let _asyncIterator_ be ! ObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »). From 9d57420f471a6f180121062d0797166229b889ad Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 13:10:29 -0500 Subject: [PATCH 26/44] Markup: entity-encode « and » --- spec.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec.html b/spec.html index 2ba7fa48c7..f097860f74 100644 --- a/spec.html +++ b/spec.html @@ -3053,7 +3053,7 @@

                Await

                1. Let _asyncContext_ be the running execution context. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _promise_ »). + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _promise_ »). 1. Let _onFulfilled_ be a new built-in function object as defined in . 1. Let _onRejected_ be a new built-in function object as defined in . 1. Set _onFulfilled_ and _onRejected_'s [[AsyncContext]] internal slots to _asyncContext_. @@ -17168,14 +17168,14 @@

                Runtime Semantics: LabelledEvaluation

                IterationStatement : `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement - 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(« », |AssignmentExpression|, ~async-iterate~). + 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(« », |AssignmentExpression|, ~async-iterate~). 1. Return ? ForIn/OfBodyEvaluation(|LeftHandSideExpression|, |Statement|, _keyResult_, ~assignment~, _labelSet_, ~async~). IterationStatement : `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement - 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(« », |AssignmentExpression|, ~async-iterate~). + 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(« », |AssignmentExpression|, ~async-iterate~). 1. Return ? ForIn/OfBodyEvaluation(|ForBinding|, |Statement|, _keyResult_, ~varBinding~, _labelSet_, ~async~). @@ -20034,7 +20034,7 @@

                Runtime Semantics: EvaluateBody

                1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_). - 1. Let _generator_ be ? OrdinaryCreateFromConstructor(_functionObject_, `"%AsyncGeneratorPrototype%"`, « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]] »). + 1. Let _generator_ be ? OrdinaryCreateFromConstructor(_functionObject_, `"%AsyncGeneratorPrototype%"`, « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]] »). 1. Perform ! AsyncGeneratorStart(_generator_, _FunctionBody_). 1. Return Completion{[[Type]]: ~return~, [[Value]]: _generator_, [[Target]]: ~empty~}. @@ -38242,7 +38242,7 @@

                AsyncGeneratorReject ( _generator_, _exception_ )

                1. Assert: _queue_ is not an empty List. 1. Remove the first element from _queue_ and let _next_ be the value of that element. 1. Let _promiseCapability_ be _next_.[[Capability]]. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _exception_ »). + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _exception_ »). 1. Perform ! AsyncGeneratorResumeNext(_generator_). 1. Return *undefined*.
                @@ -38268,7 +38268,7 @@

                AsyncGeneratorResumeNext ( _generator_ )

                1. If _completion_.[[Type]] is ~return~: 1. Set _generator_.[[AsyncGeneratorState]] to `"awaiting-return"`. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _completion_.[[Value]] »). + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _completion_.[[Value]] »). 1. Let _onFulfilled_ be a new built-in function object as defined in . 1. Let _onRejected_ be a new built-in function object as defined in . 1. Set _onFulfilled_ and _onRejected_'s [[Generator]] internal slots to _generator_. From 4caf1479baf32f7807bd30decbc92a5b09d84846 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 15:04:23 -0500 Subject: [PATCH 27/44] Editorial: "was not passed" -> "is not present" --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index f097860f74..3ab72021e2 100644 --- a/spec.html +++ b/spec.html @@ -4962,7 +4962,7 @@

                Operations on Iterator Objects

                GetIterator ( _obj_ [ , _hint_ [ , _method_ ] ] )

                The abstract operation GetIterator with argument _obj_ and optional arguments _hint_ and _method_ performs the following steps:

                - 1. If _hint_ was not passed, let _hint_ be ~normal~. + 1. If _hint_ is not present, let _hint_ be ~normal~. 1. If _method_ is not present, then 1. If _hint_ is ~async~, 1. Set _method_ to ? GetMethod(_obj_, @@asyncIterator). @@ -17224,7 +17224,7 @@

                Runtime Semantics: ForIn/OfHeadEvaluation ( _TDZnames_, _expr_, _iterationKi

                Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_ [ , _iteratorKind_ ])

                The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _lhsKind_, labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~normal~ or ~async~.

                - 1. If _iteratorKind_ was not passed, let _iteratorKind_ be ~normal~. + 1. If _iteratorKind_ is not present, let _iteratorKind_ be ~normal~. 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. 1. Let _V_ be *undefined*. 1. Let _destructuring_ be IsDestructuring of _lhs_. From b7c261fea43e3a93c7f9d250437b94f44cf2b14a Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 15:33:11 -0500 Subject: [PATCH 28/44] Editorial: "the `this` value" -> "the *this* value" (It's debateable whether the latter is correct, but it's certainly more common.) --- spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index 3ab72021e2..21cce1700c 100644 --- a/spec.html +++ b/spec.html @@ -38106,7 +38106,7 @@

                AsyncGenerator.prototype.constructor

                AsyncGenerator.prototype.next ( _value_ )

                - 1. Let _generator_ be the `this` value. + 1. Let _generator_ be the *this* value. 1. Let _completion_ be NormalCompletion(_value_). 1. Return ! AsyncGeneratorEnqueue(_generator_, _completion_). @@ -38115,7 +38115,7 @@

                AsyncGenerator.prototype.next ( _value_ )

                AsyncGenerator.prototype.return ( _value_ )

                - 1. Let _generator_ be the `this` value. + 1. Let _generator_ be the *this* value. 1. Let _completion_ be Completion{[[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~}. 1. Return ! AsyncGeneratorEnqueue(_generator_, _completion_). @@ -38124,7 +38124,7 @@

                AsyncGenerator.prototype.return ( _value_ )

                AsyncGenerator.prototype.throw ( _exception_ )

                - 1. Let _generator_ be the `this` value. + 1. Let _generator_ be the *this* value. 1. Let _completion_ be Completion{[[Type]]: ~throw~, [[Value]]: _exception_, [[Target]]: ~empty~}. 1. Return ! AsyncGeneratorEnqueue(_generator_, _completion_). From 3267bc1cba59df0846f40a5aa9477ff3635db4cb Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 15:47:05 -0500 Subject: [PATCH 29/44] Editorial: normalize syntax of 'if' steps --- spec.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec.html b/spec.html index 21cce1700c..b27107c9d0 100644 --- a/spec.html +++ b/spec.html @@ -4964,9 +4964,9 @@

                GetIterator ( _obj_ [ , _hint_ [ , _method_ ] ] )

                1. If _hint_ is not present, let _hint_ be ~normal~. 1. If _method_ is not present, then - 1. If _hint_ is ~async~, + 1. If _hint_ is ~async~, then 1. Set _method_ to ? GetMethod(_obj_, @@asyncIterator). - 1. If _method_ is *undefined*, + 1. If _method_ is *undefined*, then 1. Let _syncMethod_ be ? GetMethod(_obj_, @@iterator). 1. Let _syncIteratorRecord_ be ? GetIterator(_obj_, ~normal~, _syncMethod_). 1. Return ? CreateAsyncFromSyncIterator(_syncIteratorRecord_). @@ -19856,7 +19856,7 @@

                Runtime Semantics: Evaluation

                1. Else, 1. Assert: _received_.[[Type]] is ~return~. 1. Let _return_ be ? GetMethod(_iterator_, `"return"`). - 1. If _return_ is *undefined*, then: + 1. If _return_ is *undefined*, then 1. If _generatorKind_ is ~async~, then set _received_.[[Value]] to ? Await(_received_.[[Value]]). 1. Return Completion(_received_). 1. Let _innerReturnResult_ be ? Call(_return_, _iterator_, « _received_.[[Value]] »). @@ -25262,7 +25262,7 @@

                Runtime Semantics: CreateDynamicFunction( _constructor_, _newTarget_, _kind_ 1. Let _goal_ be the grammar symbol |GeneratorBody|. 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[+Yield, ~Await]|. 1. Let _fallbackProto_ be `"%Generator%"`. - 1. Else if _kind_ is `"async"`, + 1. Else if _kind_ is `"async"`, then 1. Assert: _kind_ is `"async"`. 1. Let _goal_ be the grammar symbol |AsyncFunctionBody|. 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[~Yield, +Await]|. @@ -37561,7 +37561,7 @@

                %AsyncFromSyncIteratorPrototype%.return ( _value_ )

                1. Return _promiseCapability_.[[Promise]]. 1. Let _returnResult_ be Call(_return_, _syncIterator_, « _value_ »). 1. IfAbruptRejectPromise(_returnResult_, _promiseCapability_). - 1. If Type(_returnResult_) is not *Object*, + 1. If Type(_returnResult_) is not *Object*, then 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _returnDone_ be IteratorComplete(_returnResult_). @@ -37595,7 +37595,7 @@

                %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

                1. Return _promiseCapability_.[[Promise]]. 1. Let _throwResult_ be Call(_throw_, _syncIterator_, « _value_ »). 1. IfAbruptRejectPromise(_throwResult_, _promiseCapability_). - 1. If Type(_throwResult_) is not *Object*, + 1. If Type(_throwResult_) is not *Object*, then 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _throwDone_ be IteratorComplete(_throwResult_). @@ -38265,7 +38265,7 @@

                AsyncGeneratorResumeNext ( _generator_ )

                1. Set _generator_.[[AsyncGeneratorState]] to `"completed"`. 1. Set _state_ to `"completed"`. 1. If _state_ is `"completed"`, then - 1. If _completion_.[[Type]] is ~return~: + 1. If _completion_.[[Type]] is ~return~, then 1. Set _generator_.[[AsyncGeneratorState]] to `"awaiting-return"`. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _completion_.[[Value]] »). @@ -38280,7 +38280,7 @@

                AsyncGeneratorResumeNext ( _generator_ )

                1. Assert: _completion_.[[Type]] is ~throw~. 1. Perform ! AsyncGeneratorReject(_generator_, _completion_.[[Value]]). 1. Return *undefined*. - 1. Else if _state_ is `"completed"`, then return ! AsyncGeneratorResolve(_generator_, *undefined*, *true*). + 1. Else if _state_ is `"completed"`, return ! AsyncGeneratorResolve(_generator_, *undefined*, *true*). 1. Assert: _state_ is either `"suspendedStart"` or `"suspendedYield"`. 1. Let _genContext_ be _generator_.[[AsyncGeneratorContext]]. 1. Let _callerContext_ be the running execution context. From c02f03ce7a54cd07fafd958491dceb41b69ee247 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 15:48:20 -0500 Subject: [PATCH 30/44] Editorial: insert dot at end of step --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index b27107c9d0..03afb69e53 100644 --- a/spec.html +++ b/spec.html @@ -25268,7 +25268,7 @@

                Runtime Semantics: CreateDynamicFunction( _constructor_, _newTarget_, _kind_ 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[~Yield, +Await]|. 1. Let _fallbackProto_ be `"%AsyncFunctionPrototype%"`. 1. Else, - 1. Assert: _kind_ is `"async generator"` + 1. Assert: _kind_ is `"async generator"`. 1. Let _goal_ be the grammar symbol |AsyncGeneratorBody|. 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[+Yield, +Await]|. 1. Let _fallbackProto_ be `"%AsyncGenerator%"`. From a854d4bb23d76892176eeef5e5bdc208bb7bf952 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Fri, 2 Feb 2018 15:59:16 -0500 Subject: [PATCH 31/44] Editorial: "*TypeError* exception" -> "*TypeError* object" (There's no such thing as "an exception".) --- spec.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec.html b/spec.html index 03afb69e53..09cf49aa50 100644 --- a/spec.html +++ b/spec.html @@ -37523,8 +37523,8 @@

                %AsyncFromSyncIteratorPrototype%.next ( _value_ )

                1. Let _O_ be the *this* value. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _invalidIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). + 1. Let _invalidIteratorError_ be a newly created *TypeError* object. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]]. 1. Let _nextResult_ be IteratorNext(_syncIteratorRecord_, _value_). @@ -37549,8 +37549,8 @@

                %AsyncFromSyncIteratorPrototype%.return ( _value_ )

                1. Let _O_ be the *this* value. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _invalidIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). + 1. Let _invalidIteratorError_ be a newly created *TypeError* object. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. 1. Let _return_ be GetMethod(_syncIterator_, `"return"`). @@ -37561,8 +37561,8 @@

                %AsyncFromSyncIteratorPrototype%.return ( _value_ )

                1. Return _promiseCapability_.[[Promise]]. 1. Let _returnResult_ be Call(_return_, _syncIterator_, « _value_ »). 1. IfAbruptRejectPromise(_returnResult_, _promiseCapability_). - 1. If Type(_returnResult_) is not *Object*, then - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). + 1. If Type(_returnResult_) is not Object, then + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _returnDone_ be IteratorComplete(_returnResult_). 1. IfAbruptRejectPromise(_returnDone_, _promiseCapability_). @@ -37584,8 +37584,8 @@

                %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

                1. Let _O_ be the *this* value. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then - 1. Let _invalidIteratorError_ be a new *TypeError* exception. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). + 1. Let _invalidIteratorError_ be a newly created *TypeError* object. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. 1. Let _throw_ be GetMethod(_syncIterator_, `"throw"`). @@ -37595,8 +37595,8 @@

                %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

                1. Return _promiseCapability_.[[Promise]]. 1. Let _throwResult_ be Call(_throw_, _syncIterator_, « _value_ »). 1. IfAbruptRejectPromise(_throwResult_, _promiseCapability_). - 1. If Type(_throwResult_) is not *Object*, then - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a *TypeError* exception »). + 1. If Type(_throwResult_) is not Object, then + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _throwDone_ be IteratorComplete(_throwResult_). 1. IfAbruptRejectPromise(_throwDone_, _promiseCapability_). @@ -38330,7 +38330,7 @@

                AsyncGeneratorEnqueue ( _generator_, _completion_ )

                1. Assert: _completion_ is a Completion Record. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_generator_) is not Object, or if _generator_ does not have an [[AsyncGeneratorState]] internal slot, then - 1. Let _badGeneratorError_ be a new *TypeError* exception. + 1. Let _badGeneratorError_ be a newly created *TypeError* object. 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badGeneratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _queue_ be _generator_.[[AsyncGeneratorQueue]]. From 201f9cd0433d71fbda1caf54a9f18ed79f52c645 Mon Sep 17 00:00:00 2001 From: Brian Terlson Date: Tue, 13 Feb 2018 17:19:11 -0800 Subject: [PATCH 32/44] Editorial: fix error name regression introduced by cherry-pick --- spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index 09cf49aa50..2e00cc9d3a 100644 --- a/spec.html +++ b/spec.html @@ -37524,7 +37524,7 @@

                %AsyncFromSyncIteratorPrototype%.next ( _value_ )

                1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then 1. Let _invalidIteratorError_ be a newly created *TypeError* object. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]]. 1. Let _nextResult_ be IteratorNext(_syncIteratorRecord_, _value_). @@ -37550,7 +37550,7 @@

                %AsyncFromSyncIteratorPrototype%.return ( _value_ )

                1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then 1. Let _invalidIteratorError_ be a newly created *TypeError* object. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. 1. Let _return_ be GetMethod(_syncIterator_, `"return"`). @@ -37585,7 +37585,7 @@

                %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

                1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then 1. Let _invalidIteratorError_ be a newly created *TypeError* object. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _badIteratorError_ »). + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIterator_ be _O_.[[SyncIteratorRecord]].[[Iterator]]. 1. Let _throw_ be GetMethod(_syncIterator_, `"throw"`). From f98cffae010a1aade4eda8379b4aaaab0222084b Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Tue, 13 Feb 2018 21:09:39 -0500 Subject: [PATCH 33/44] Editorial: use CreateBuiltinFunction() --- spec.html | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/spec.html b/spec.html index 2e00cc9d3a..237f227348 100644 --- a/spec.html +++ b/spec.html @@ -3054,9 +3054,13 @@

                Await

                1. Let _asyncContext_ be the running execution context. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _promise_ »). - 1. Let _onFulfilled_ be a new built-in function object as defined in . - 1. Let _onRejected_ be a new built-in function object as defined in . - 1. Set _onFulfilled_ and _onRejected_'s [[AsyncContext]] internal slots to _asyncContext_. + 1. Let _realm_ be the current Realm Record. + 1. Let _stepsFulfilled_ be the algorithm steps defined in . + 1. Let _onFulfilled_ be CreateBuiltinFunction(_realm_, _stepsFulfilled_, %FunctionPrototype%, « [[AsyncContext]] »). + 1. Set _onFulfilled_.[[AsyncContext]] to _asyncContext_. + 1. Let _stepsRejected_ be the algorithm steps defined in . + 1. Let _onRejected_ be CreateBuiltinFunction(_realm_, _stepsRejected_, %FunctionPrototype%, « [[AsyncContext]] »). + 1. Set _onRejected_.[[AsyncContext]] to _asyncContext_. 1. Let _throwawayCapability_ be NewPromiseCapability(%Promise%). 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). @@ -37535,7 +37539,9 @@

                %AsyncFromSyncIteratorPrototype%.next ( _value_ )

                1. IfAbruptRejectPromise(_nextValue_, _promiseCapability_). 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _nextValue_ »). - 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Let _realm_ be the current Realm Record. + 1. Let _steps_ be the algorithm steps defined in . + 1. Let _onFulfilled_ be CreateBuiltinFunction(_realm_, _steps_, %FunctionPrototype%, « [[Done]] »). 1. Set _onFulfilled_.[[Done]] to _nextDone_. 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). 1. Return _promiseCapability_.[[Promise]]. @@ -37570,7 +37576,9 @@

                %AsyncFromSyncIteratorPrototype%.return ( _value_ )

                1. IfAbruptRejectPromise(_returnValue_, _promiseCapability_). 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _returnValue_ »). - 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Let _realm_ be the current Realm Record. + 1. Let _steps_ be the algorithm steps defined in . + 1. Let _onFulfilled_ be CreateBuiltinFunction(_realm_, _steps_, %FunctionPrototype%, « [[Done]] »). 1. Set _onFulfilled_.[[Done]] to _returnDone_. 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). 1. Return _promiseCapability_.[[Promise]]. @@ -37604,7 +37612,9 @@

                %AsyncFromSyncIteratorPrototype%.throw ( _value_ )

                1. IfAbruptRejectPromise(_throwValue_, _promiseCapability_). 1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%). 1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, « _throwValue_ »). - 1. Let _onFulfilled_ be a new built-in function object as defined in . + 1. Let _realm_ be the current Realm Record. + 1. Let _steps_ be the algorithm steps defined in . + 1. Let _onFulfilled_ be CreateBuiltinFunction(_realm_, _steps_, %FunctionPrototype%, « [[Done]] »). 1. Set _onFulfilled_.[[Done]] to _throwDone_. 1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_). 1. Return _promiseCapability_.[[Promise]]. @@ -38269,9 +38279,13 @@

                AsyncGeneratorResumeNext ( _generator_ )

                1. Set _generator_.[[AsyncGeneratorState]] to `"awaiting-return"`. 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _completion_.[[Value]] »). - 1. Let _onFulfilled_ be a new built-in function object as defined in . - 1. Let _onRejected_ be a new built-in function object as defined in . - 1. Set _onFulfilled_ and _onRejected_'s [[Generator]] internal slots to _generator_. + 1. Let _realm_ be the current Realm Record. + 1. Let _stepsFulfilled_ be the algorithm steps defined in . + 1. Let _onFulfilled_ be CreateBuiltinFunction(_realm_, _stepsFulfilled_, %FunctionPrototype%, « [[Generator]] »). + 1. Set _onFulfilled_.[[Generator]] to _generator_. + 1. Let _stepsRejected_ be the algorithm steps defined in . + 1. Let _onRejected_ be CreateBuiltinFunction(_realm_, _stepsRejected_, %FunctionPrototype%, « [[Generator]] »). + 1. Set _onRejected_.[[Generator]] to _generator_. 1. Let _throwawayCapability_ be NewPromiseCapability(%Promise%). 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). From 134cf5eeeb71282bd08a745d13c669c1493f8bfb Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Tue, 13 Feb 2018 21:20:21 -0500 Subject: [PATCH 34/44] Editorial: Delete extra space. --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 237f227348..9d64cd0f56 100644 --- a/spec.html +++ b/spec.html @@ -37528,7 +37528,7 @@

                %AsyncFromSyncIteratorPrototype%.next ( _value_ )

                1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. If Type(_O_) is not Object, or if _O_ does not have a [[SyncIteratorRecord]] internal slot, then 1. Let _invalidIteratorError_ be a newly created *TypeError* object. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _invalidIteratorError_ »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]]. 1. Let _nextResult_ be IteratorNext(_syncIteratorRecord_, _value_). From 79c0d4e7af14f733ddaeafddb64d0394f512ec27 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Tue, 13 Feb 2018 21:20:43 -0500 Subject: [PATCH 35/44] Editorial: fix malformed parameter name --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 9d64cd0f56..bc6d299949 100644 --- a/spec.html +++ b/spec.html @@ -17226,7 +17226,7 @@

                Runtime Semantics: ForIn/OfHeadEvaluation ( _TDZnames_, _expr_, _iterationKi

                Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_ [ , _iteratorKind_ ])

                -

                The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _lhsKind_, labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~normal~ or ~async~.

                +

                The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _lhsKind_, _labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~normal~ or ~async~.

                1. If _iteratorKind_ is not present, let _iteratorKind_ be ~normal~. 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. From 83974e0a82700344fa6026a903d1dfd304e6f997 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Tue, 13 Feb 2018 21:21:54 -0500 Subject: [PATCH 36/44] Editorial: add _iterationKind_ to ForIn/OfBodyEvaluation's preamble --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index bc6d299949..06b0852878 100644 --- a/spec.html +++ b/spec.html @@ -17226,7 +17226,7 @@

                Runtime Semantics: ForIn/OfHeadEvaluation ( _TDZnames_, _expr_, _iterationKi

                Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_ [ , _iteratorKind_ ])

                -

                The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _lhsKind_, _labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~normal~ or ~async~.

                +

                The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~normal~ or ~async~.

                1. If _iteratorKind_ is not present, let _iteratorKind_ be ~normal~. 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. From 53402011c11230180fd3c0a98bec0fd19e533d59 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Tue, 13 Feb 2018 21:42:30 -0500 Subject: [PATCH 37/44] Editorial: "production" -> "Parse Node" --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 06b0852878..b8db906537 100644 --- a/spec.html +++ b/spec.html @@ -7660,7 +7660,7 @@

                GeneratorFunctionCreate ( _kind_, _ParameterList_, _Body_, _Scope_, _Strict_

                AsyncGeneratorFunctionCreate (_kind_, _ParameterList_, _Body_, _Scope_, _Strict_)

                -

                The abstract operation AsyncGeneratorFunctionCreate requires the arguments: _kind_ which is one of (~Normal~, ~Method~), a parameter list production specified by _ParameterList_, a body production specified by _Body_, a Lexical Environment specified by _Scope_, and a Boolean flag _Strict_. AsyncGeneratorFunctionCreate performs the following steps:

                +

                The abstract operation AsyncGeneratorFunctionCreate requires the arguments: _kind_ which is one of (~Normal~, ~Method~), a parameter list Parse Node specified by _ParameterList_, a body Parse Node specified by _Body_, a Lexical Environment specified by _Scope_, and a Boolean flag _Strict_. AsyncGeneratorFunctionCreate performs the following steps:

                1. Let _functionPrototype_ be the intrinsic object %AsyncGenerator%. 1. Let _F_ be ! FunctionAllocate(_functionPrototype_, _Strict_, `"generator"`). From 57300e460fded7f8163eebe01a75845bb9ddcb82 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 14 Feb 2018 13:57:52 -0500 Subject: [PATCH 38/44] Editorial: put "!" before "NewPromiseCapability(%Promise%)" --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index b8db906537..c2ea31d034 100644 --- a/spec.html +++ b/spec.html @@ -3061,7 +3061,7 @@

                Await

                1. Let _stepsRejected_ be the algorithm steps defined in . 1. Let _onRejected_ be CreateBuiltinFunction(_realm_, _stepsRejected_, %FunctionPrototype%, « [[AsyncContext]] »). 1. Set _onRejected_.[[AsyncContext]] to _asyncContext_. - 1. Let _throwawayCapability_ be NewPromiseCapability(%Promise%). + 1. Let _throwawayCapability_ be ! NewPromiseCapability(%Promise%). 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). 1. Remove _asyncContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. @@ -38286,7 +38286,7 @@

                AsyncGeneratorResumeNext ( _generator_ )

                1. Let _stepsRejected_ be the algorithm steps defined in . 1. Let _onRejected_ be CreateBuiltinFunction(_realm_, _stepsRejected_, %FunctionPrototype%, « [[Generator]] »). 1. Set _onRejected_.[[Generator]] to _generator_. - 1. Let _throwawayCapability_ be NewPromiseCapability(%Promise%). + 1. Let _throwawayCapability_ be ! NewPromiseCapability(%Promise%). 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). 1. Return *undefined*. From a6aed7b5c652a3eb689e01f4bc52432be0f21283 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 14 Feb 2018 13:58:47 -0500 Subject: [PATCH 39/44] Editorial: insert missing _iterationKind_ argument ... in 3 invocations of ForIn/OfBodyEvaluation. (I'm *pretty* sure that it has to be ~iterate~, but please check.) --- spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index c2ea31d034..bf0107da11 100644 --- a/spec.html +++ b/spec.html @@ -17173,21 +17173,21 @@

                Runtime Semantics: LabelledEvaluation

                1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(« », |AssignmentExpression|, ~async-iterate~). - 1. Return ? ForIn/OfBodyEvaluation(|LeftHandSideExpression|, |Statement|, _keyResult_, ~assignment~, _labelSet_, ~async~). + 1. Return ? ForIn/OfBodyEvaluation(|LeftHandSideExpression|, |Statement|, _keyResult_, ~iterate~, ~assignment~, _labelSet_, ~async~). IterationStatement : `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(« », |AssignmentExpression|, ~async-iterate~). - 1. Return ? ForIn/OfBodyEvaluation(|ForBinding|, |Statement|, _keyResult_, ~varBinding~, _labelSet_, ~async~). + 1. Return ? ForIn/OfBodyEvaluation(|ForBinding|, |Statement|, _keyResult_, ~iterate~, ~varBinding~, _labelSet_, ~async~). IterationStatement : `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(BoundNames of |ForDeclaration|, |AssignmentExpression|, ~async-iterate~). - 1. Return ? ForIn/OfBodyEvaluation(|ForDeclaration|, |Statement|, _keyResult_, ~lexicalBinding~, _labelSet_, ~async~). + 1. Return ? ForIn/OfBodyEvaluation(|ForDeclaration|, |Statement|, _keyResult_, ~iterate~, ~lexicalBinding~, _labelSet_, ~async~).

                This section is extended by Annex .

                From 4abc04ac4ba61325eb0d1534e58f9c9319ccd595 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 14 Feb 2018 14:02:13 -0500 Subject: [PATCH 40/44] Editorial: "let" -> "set" --- spec.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec.html b/spec.html index bf0107da11..0951b93e17 100644 --- a/spec.html +++ b/spec.html @@ -4966,7 +4966,7 @@

                Operations on Iterator Objects

                GetIterator ( _obj_ [ , _hint_ [ , _method_ ] ] )

                The abstract operation GetIterator with argument _obj_ and optional arguments _hint_ and _method_ performs the following steps:

                - 1. If _hint_ is not present, let _hint_ be ~normal~. + 1. If _hint_ is not present, set _hint_ to ~normal~. 1. If _method_ is not present, then 1. If _hint_ is ~async~, then 1. Set _method_ to ? GetMethod(_obj_, @@asyncIterator). @@ -17228,7 +17228,7 @@

                Runtime Semantics: ForIn/OfHeadEvaluation ( _TDZnames_, _expr_, _iterationKi

                Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_ [ , _iteratorKind_ ])

                The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~normal~ or ~async~.

                - 1. If _iteratorKind_ is not present, let _iteratorKind_ be ~normal~. + 1. If _iteratorKind_ is not present, set _iteratorKind_ to ~normal~. 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. 1. Let _V_ be *undefined*. 1. Let _destructuring_ be IsDestructuring of _lhs_. @@ -17285,7 +17285,7 @@

                Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, 1. Return Completion(UpdateEmpty(_result_, _V_)). 1. Else, 1. Assert: _iterationKind_ is ~iterate~. - 1. Let _status_ be UpdateEmpty(_result_, _V_). + 1. Set _status_ to UpdateEmpty(_result_, _V_). 1. If _iteratorKind_ is ~async~, return ? AsyncIteratorClose(_iteratorRecord_, _status_). 1. Return ? IteratorClose(_iteratorRecord_, _status_). 1. If _result_.[[Value]] is not ~empty~, set _V_ to _result_.[[Value]]. @@ -19836,8 +19836,8 @@

                Runtime Semantics: Evaluation

                1. Let _done_ be ? IteratorComplete(_innerResult_). 1. If _done_ is *true*, then 1. Return ? IteratorValue(_innerResult_). - 1. If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)). - 1. Else, let _received_ be GeneratorYield(_innerResult_). + 1. If _generatorKind_ is ~async~, then set _received_ to AsyncGeneratorYield(? IteratorValue(_innerResult_)). + 1. Else, set _received_ to GeneratorYield(_innerResult_). 1. Else if _received_.[[Type]] is ~throw~, then 1. Let _throw_ be ? GetMethod(_iterator_, `"throw"`). 1. If _throw_ is not *undefined*, then @@ -19848,8 +19848,8 @@

                Runtime Semantics: Evaluation

                1. Let _done_ be ? IteratorComplete(_innerResult_). 1. If _done_ is *true*, then 1. Return ? IteratorValue(_innerResult_). - 1. If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)). - 1. Else, let _received_ be GeneratorYield(_innerResult_). + 1. If _generatorKind_ is ~async~, then set _received_ to AsyncGeneratorYield(? IteratorValue(_innerResult_)). + 1. Else, set _received_ to GeneratorYield(_innerResult_). 1. Else, 1. NOTE: If _iterator_ does not have a `throw` method, this throw is going to terminate the `yield*` loop. But first we need to give _iterator_ a chance to clean up. 1. Let _closeCompletion_ be Completion{[[Type]]: ~normal~, [[Value]]: ~empty~, [[Target]]: ~empty~}. @@ -19870,8 +19870,8 @@

                Runtime Semantics: Evaluation

                1. If _done_ is *true*, then 1. Let _value_ be ? IteratorValue(_innerReturnResult_). 1. Return Completion{[[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~}. - 1. If _generatorKind_ is ~async~, then let _received_ be AsyncGeneratorYield(? IteratorValue(_innerResult_)). - 1. Else, let _received_ be GeneratorYield(_innerResult_). + 1. If _generatorKind_ is ~async~, then set _received_ to AsyncGeneratorYield(? IteratorValue(_innerResult_)). + 1. Else, set _received_ to GeneratorYield(_innerResult_).
                From 2a488727a29507fe94353194f95e72498b6ee113 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 14 Feb 2018 14:03:10 -0500 Subject: [PATCH 41/44] Editorial: _FunctionBody_ -> |FunctionBody| --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 0951b93e17..6f8619e143 100644 --- a/spec.html +++ b/spec.html @@ -20039,7 +20039,7 @@

                Runtime Semantics: EvaluateBody

                1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_). 1. Let _generator_ be ? OrdinaryCreateFromConstructor(_functionObject_, `"%AsyncGeneratorPrototype%"`, « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]] »). - 1. Perform ! AsyncGeneratorStart(_generator_, _FunctionBody_). + 1. Perform ! AsyncGeneratorStart(_generator_, |FunctionBody|). 1. Return Completion{[[Type]]: ~return~, [[Value]]: _generator_, [[Target]]: ~empty~}. From f3c9c78cd16ce2b3daa0502e360d4e2ea7d94114 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 14 Feb 2018 14:07:19 -0500 Subject: [PATCH 42/44] Editorial: _innerResult_ -> _innerReturnResult_ (I don't think _innerResult_ is guaranteed to be set at these points, and it seems like there's more to be done with_innerReturnResult_.) --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index 6f8619e143..c734587315 100644 --- a/spec.html +++ b/spec.html @@ -19870,8 +19870,8 @@

                Runtime Semantics: Evaluation

                1. If _done_ is *true*, then 1. Let _value_ be ? IteratorValue(_innerReturnResult_). 1. Return Completion{[[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~}. - 1. If _generatorKind_ is ~async~, then set _received_ to AsyncGeneratorYield(? IteratorValue(_innerResult_)). - 1. Else, set _received_ to GeneratorYield(_innerResult_). + 1. If _generatorKind_ is ~async~, then set _received_ to AsyncGeneratorYield(? IteratorValue(_innerReturnResult_)). + 1. Else, set _received_ to GeneratorYield(_innerReturnResult_). From 3e81f7146d0323b14f13efec7981536871d11bab Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 14 Feb 2018 14:26:26 -0500 Subject: [PATCH 43/44] Editorial: ~normal~ -> ~sync~ ... to distinguish it from the ~normal~ value that appears in the [[Type]] field of Completion Records, and also to better contrast it with the ~async~ value. --- spec.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec.html b/spec.html index c734587315..e402663d69 100644 --- a/spec.html +++ b/spec.html @@ -4966,13 +4966,13 @@

                Operations on Iterator Objects

                GetIterator ( _obj_ [ , _hint_ [ , _method_ ] ] )

                The abstract operation GetIterator with argument _obj_ and optional arguments _hint_ and _method_ performs the following steps:

                - 1. If _hint_ is not present, set _hint_ to ~normal~. + 1. If _hint_ is not present, set _hint_ to ~sync~. 1. If _method_ is not present, then 1. If _hint_ is ~async~, then 1. Set _method_ to ? GetMethod(_obj_, @@asyncIterator). 1. If _method_ is *undefined*, then 1. Let _syncMethod_ be ? GetMethod(_obj_, @@iterator). - 1. Let _syncIteratorRecord_ be ? GetIterator(_obj_, ~normal~, _syncMethod_). + 1. Let _syncIteratorRecord_ be ? GetIterator(_obj_, ~sync~, _syncMethod_). 1. Return ? CreateAsyncFromSyncIterator(_syncIteratorRecord_). 1. Otherwise, set _method_ to ? GetMethod(_obj_, @@iterator). 1. Let _iterator_ be ? Call(_method_, _obj_). @@ -17218,7 +17218,7 @@

                Runtime Semantics: ForIn/OfHeadEvaluation ( _TDZnames_, _expr_, _iterationKi 1. Else, 1. Assert: _iterationKind_ is ~iterate~. 1. If _iterationKind_ is ~async-iterate~, let _iteratorHint_ be ~async~. - 1. Else, let _iteratorHint_ be ~normal~. + 1. Else, let _iteratorHint_ be ~sync~. 1. Return ? GetIterator(_exprValue_, _iteratorHint_). @@ -17226,9 +17226,9 @@

                Runtime Semantics: ForIn/OfHeadEvaluation ( _TDZnames_, _expr_, _iterationKi

                Runtime Semantics: ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_ [ , _iteratorKind_ ])

                -

                The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~normal~ or ~async~.

                +

                The abstract operation ForIn/OfBodyEvaluation is called with arguments _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_, _labelSet_, and optional argument _iteratorKind_. The value of _lhsKind_ is either ~assignment~, ~varBinding~ or ~lexicalBinding~. The value of _iteratorKind_ is either ~sync~ or ~async~.

                - 1. If _iteratorKind_ is not present, set _iteratorKind_ to ~normal~. + 1. If _iteratorKind_ is not present, set _iteratorKind_ to ~sync~. 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. 1. Let _V_ be *undefined*. 1. Let _destructuring_ be IsDestructuring of _lhs_. @@ -32157,7 +32157,7 @@

                Array.from ( _items_ [ , _mapfn_ [ , _thisArg_ ] ] )

                1. Let _A_ be ? Construct(_C_). 1. Else, 1. Let _A_ be ! ArrayCreate(0). - 1. Let _iteratorRecord_ be ? GetIterator(_items_, ~normal~, _usingIterator_). + 1. Let _iteratorRecord_ be ? GetIterator(_items_, ~sync~, _usingIterator_). 1. Let _k_ be 0. 1. Repeat, 1. If _k_ ≥ 253-1, then @@ -33788,7 +33788,7 @@

                %TypedArray%.from ( _source_ [ , _mapfn_ [ , _thisArg_ ] ] )

                Runtime Semantics: IterableToList( _items_, _method_ )

                The abstract operation IterableToList performs the following steps:

                - 1. Let _iteratorRecord_ be ? GetIterator(_items_, ~normal~, _method_). + 1. Let _iteratorRecord_ be ? GetIterator(_items_, ~sync~, _method_). 1. Let _values_ be a new empty List. 1. Let _next_ be *true*. 1. Repeat, while _next_ is not *false* @@ -38068,7 +38068,7 @@

                GetGeneratorKind ( )

                1. If _genContext_ does not have a Generator component, return ~non-generator~. 1. Let _generator_ be the Generator component of _genContext_. 1. If _generator_ has an [[AsyncGeneratorState]] internal slot, return ~async~. - 1. Else, return ~normal~. + 1. Else, return ~sync~.
                @@ -38081,7 +38081,7 @@

                GeneratorYield ( _iterNextObj_ )

                1. Let _genContext_ be the running execution context. 1. Assert: _genContext_ is the execution context of a generator. 1. Let _generator_ be the value of the Generator component of _genContext_. - 1. Assert: GetGeneratorKind() is ~normal~. + 1. Assert: GetGeneratorKind() is ~sync~. 1. Set _generator_.[[GeneratorState]] to `"suspendedYield"`. 1. Remove _genContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. 1. Set the code evaluation state of _genContext_ such that when evaluation is resumed with a Completion _resumptionValue_ the following steps will be performed: From 2b4e469d2ae2e094a6844c27aa973b4316279708 Mon Sep 17 00:00:00 2001 From: Brian Terlson Date: Wed, 14 Feb 2018 13:18:55 -0800 Subject: [PATCH 44/44] Editorial: add assert to GetIterator --- spec.html | 1 + 1 file changed, 1 insertion(+) diff --git a/spec.html b/spec.html index e402663d69..8ae9d81c68 100644 --- a/spec.html +++ b/spec.html @@ -4967,6 +4967,7 @@

                GetIterator ( _obj_ [ , _hint_ [ , _method_ ] ] )

                The abstract operation GetIterator with argument _obj_ and optional arguments _hint_ and _method_ performs the following steps:

                1. If _hint_ is not present, set _hint_ to ~sync~. + 1. Assert: _hint_ is either ~sync~ or ~async~. 1. If _method_ is not present, then 1. If _hint_ is ~async~, then 1. Set _method_ to ? GetMethod(_obj_, @@asyncIterator).

        - Binding object is the global object. It contains global built-in bindings as well as |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, and |VariableDeclaration| bindings in global code for the associated realm. + Binding object is the global object. It contains global built-in bindings as well as |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, and |VariableDeclaration| bindings in global code for the associated realm.
        - Contains bindings for all declarations in global code for the associated realm code except for |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, and |VariableDeclaration| _bindings_. + Contains bindings for all declarations in global code for the associated realm code except for |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, and |VariableDeclaration| _bindings_.
        - The string names bound by |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, and |VariableDeclaration| declarations in global code for the associated realm. + The string names bound by |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, and |VariableDeclaration| declarations in global code for the associated realm.
        - Determines if the argument identifier has a binding in this Environment Record that was created using a |VariableDeclaration|, |FunctionDeclaration|, |GeneratorDeclaration|, or |AsyncFunctionDeclaration|. + Determines if the argument identifier has a binding in this Environment Record that was created using a |VariableDeclaration|, |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, or |AsyncGeneratorDeclaration|.