diff --git a/spec.html b/spec.html index f8252b6825..a65dad7e5d 100644 --- a/spec.html +++ b/spec.html @@ -1876,6 +1876,26 @@

Well-Known Intrinsic Objects

The initial value of the `prototype` property of %Generator% + + + %AsyncFunction% + + + + + The constructor of async function objects () + + + + + %GeneratorPrototype% + + + + + The initial value of the `prototype` property of %Generator% + + %Int8Array% @@ -6861,7 +6881,6 @@

OrdinaryCallBindThis ( _F_, _calleeContext_, _thisArgument_ )

OrdinaryCallEvaluateBody ( _F_, _argumentsList_ )

When the abstract operation OrdinaryCallEvaluateBody is called with function object _F_ and List _argumentsList_, the following steps are taken:

- 1. Perform ? FunctionDeclarationInstantiation(_F_, _argumentsList_). 1. Return the result of EvaluateBody of the parsed code that is _F_.[[ECMAScriptCode]] passing _F_ as the argument. @@ -8849,7 +8868,7 @@

Types of Source Code

-

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

+

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 () and the GeneratorFunction constructor ().

@@ -9368,7 +9387,7 @@

Keywords

Syntax

Keyword :: one of - `break` `do` `in` `typeof` `case` `else` `instanceof` `var` `catch` `export` `new` `void` `class` `extends` `return` `while` `const` `finally` `super` `with` `continue` `for` `switch` `yield` `debugger` `function` `this` `default` `if` `throw` `delete` `import` `try` + `break` `do` `in` `typeof` `case` `else` `instanceof` `var` `catch` `export` `new` `void` `class` `extends` `return` `while` `const` `finally` `super` `with` `continue` `for` `switch` `yield` `debugger` `function` `this` `default` `if` `throw` `delete` `import` `try` `await`

In some contexts `yield` is given the semantics of an |Identifier|. See . In strict mode code, `let` and `static` are treated as reserved keywords through static semantic restrictions (see , , , and ) rather than the lexical grammar.

@@ -10354,31 +10373,31 @@

Rules of Automatic Semicolon Insertion

The following are the only restricted productions in the grammar:

- UpdateExpression[Yield] : - LeftHandSideExpression[?Yield] [no LineTerminator here] `++` - LeftHandSideExpression[?Yield] [no LineTerminator here] `--` + UpdateExpression[Yield, Await] : + LeftHandSideExpression[?Yield, ?Await] [no LineTerminator here] `++` + LeftHandSideExpression[?Yield, ?Await] [no LineTerminator here] `--` - ContinueStatement[Yield] : + ContinueStatement[Yield, Await] : `continue` `;` - `continue` [no LineTerminator here] LabelIdentifier[?Yield] `;` + `continue` [no LineTerminator here] LabelIdentifier[?Yield, ?Await] `;` - BreakStatement[Yield] : + BreakStatement[Yield, Await] : `break` `;` - `break` [no LineTerminator here] LabelIdentifier[?Yield] `;` + `break` [no LineTerminator here] LabelIdentifier[?Yield, ?Await] `;` - ReturnStatement[Yield] : + ReturnStatement[Yield, Await] : `return` `;` - `return` [no LineTerminator here] Expression[+In, ?Yield] `;` + `return` [no LineTerminator here] Expression[+In, ?Yield, ?Await] `;` - ThrowStatement[Yield] : - `throw` [no LineTerminator here] Expression[+In, ?Yield] `;` + ThrowStatement[Yield, Await] : + `throw` [no LineTerminator here] Expression[+In, ?Yield, ?Await] `;` - ArrowFunction[In, Yield] : - ArrowParameters[?Yield] [no LineTerminator here] `=>` ConciseBody[?In] + ArrowFunction[In, Yield, Await] : + ArrowParameters[?Yield, ?Await] [no LineTerminator here] `=>` ConciseBody[?In] - YieldExpression[In] : - `yield` [no LineTerminator here] `*` AssignmentExpression[?In, +Yield] - `yield` [no LineTerminator here] AssignmentExpression[?In, +Yield] + YieldExpression[In, Await] : + `yield` [no LineTerminator here] `*` AssignmentExpression[?In, +Yield, ?Await] + `yield` [no LineTerminator here] AssignmentExpression[?In, +Yield, ?Await]

The practical effect of these restricted productions is as follows:

- IdentifierReference[Yield] : Identifier + IdentifierReference[Yield, Await] : Identifier - BindingIdentifier[Yield] : Identifier + BindingIdentifier[Yield, Await] : Identifier - LabelIdentifier[Yield] : Identifier + LabelIdentifier[Yield, Await] : Identifier Identifier : IdentifierName but not ReservedWord -

In addition to describing an actual object initializer the |ObjectLiteral| productions are also used as a cover grammar for |ObjectAssignmentPattern|. and may be recognized as part of a |CoverParenthesizedExpressionAndArrowParameterList|. When |ObjectLiteral| appears in a context where |ObjectAssignmentPattern| is required the following Early Error rules are not applied. In addition, they are not applied when initially parsing a |CoverParenthesizedExpressionAndArrowParameterList|.

+

In addition to describing an actual object initializer the |ObjectLiteral| productions are also used as a cover grammar for |ObjectAssignmentPattern| and may be recognized as part of a |CoverParenthesizedExpressionAndArrowParameterList|. When |ObjectLiteral| appears in a context where |ObjectAssignmentPattern| is required the following Early Error rules are not applied. In addition, they are not applied when initially parsing a |CoverParenthesizedExpressionAndArrowParameterList|.

PropertyDefinition : CoverInitializedName - ArrowParameters[Yield] : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ArrowParameters[Yield, Await] : CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] @@ -18072,7 +18138,7 @@

Static Semantics: CoveredFormalsList

1. Return this |ArrowParameters|. - CoverParenthesizedExpressionAndArrowParameterList[Yield] : + CoverParenthesizedExpressionAndArrowParameterList[Yield, Await] : `(` Expression `)` `(` `)` `(` `...` BindingIdentifier `)` @@ -18081,8 +18147,7 @@

Static Semantics: CoveredFormalsList

`(` Expression `,` `...` BindingPattern `)`
- 1. If the [Yield] grammar parameter is present for |CoverParenthesizedExpressionAndArrowParameterList[Yield]|, return the result of parsing the lexical token stream matched by |CoverParenthesizedExpressionAndArrowParameterList[Yield]| using |ArrowFormalParameters[+Yield]| as the goal symbol. - 1. If the [Yield] grammar parameter is not present for |CoverParenthesizedExpressionAndArrowParameterList[Yield]|, return the result of parsing the lexical token stream matched by |CoverParenthesizedExpressionAndArrowParameterList[Yield]| using |ArrowFormalParameters[~Yield]| as the goal symbol. + 1. Return the result of parsing the lexical token stream matched by |CoverParenthesizedExpressionAndArrowParameterList| using |ArrowFormalParameters| as the goal symbol with its [Yield] and [Await] parameters set to the values used when parsing this |CoverParenthesizedExpressionAndArrowParameterList|. @@ -18153,10 +18218,11 @@

Runtime Semantics: IteratorBindingInitialization

Runtime Semantics: EvaluateBody

-

With parameter _functionObject_.

+

With parameter _functionObject_ and List _argumentsList_.

ConciseBody : AssignmentExpression + 1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_). 1. Let _exprRef_ be the result of evaluating |AssignmentExpression|. 1. Let _exprValue_ be ? GetValue(_exprRef_). 1. Return Completion{[[Type]]: ~return~, [[Value]]: _exprValue_, [[Target]]: ~empty~}. @@ -18185,14 +18251,15 @@

Runtime Semantics: Evaluation

Method Definitions

Syntax

- MethodDefinition[Yield] : - PropertyName[?Yield] `(` UniqueFormalParameters[~Yield] `)` `{` FunctionBody[~Yield] `}` - GeneratorMethod[?Yield] - `get` PropertyName[?Yield] `(` `)` `{` FunctionBody[~Yield] `}` - `set` PropertyName[?Yield] `(` PropertySetParameterList `)` `{` FunctionBody[~Yield] `}` + MethodDefinition[Yield, Await] : + PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, ~Await] `)` `{` FunctionBody[~Yield, ~Await] `}` + GeneratorMethod[?Yield, ?Await] + AsyncMethod[?Yield, ?Await] + `get` PropertyName[?Yield, ?Await] `(` `)` `{` FunctionBody[~Yield, ~Await] `}` + `set` PropertyName[?Yield, ?Await] `(` PropertySetParameterList `)` `{` FunctionBody[~Yield, ~Await] `}` PropertySetParameterList : - FormalParameter[~Yield] + FormalParameter[~Yield, ~Await] @@ -18366,23 +18433,23 @@

Runtime Semantics: PropertyDefinitionEvaluation

Generator Function Definitions

Syntax

- GeneratorMethod[Yield] : - `*` PropertyName[?Yield] `(` UniqueFormalParameters[+Yield] `)` `{` GeneratorBody `}` + GeneratorMethod[Yield, Await] : + `*` PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, ?Await] `)` `{` GeneratorBody `}` - GeneratorDeclaration[Yield, Default] : - `function` `*` BindingIdentifier[?Yield] `(` FormalParameters[+Yield] `)` `{` GeneratorBody `}` - [+Default] `function` `*` `(` FormalParameters[+Yield] `)` `{` GeneratorBody `}` + GeneratorDeclaration[Yield, Await, Default] : + `function` `*` BindingIdentifier[?Yield, ?Await] `(` FormalParameters[+Yield, ?Await] `)` `{` GeneratorBody `}` + [+Default] `function` `*` `(` FormalParameters[+Yield, ?Await] `)` `{` GeneratorBody `}` GeneratorExpression : - `function` `*` BindingIdentifier[+Yield]? `(` FormalParameters[+Yield] `)` `{` GeneratorBody `}` + `function` `*` BindingIdentifier[+Yield, ~Await]? `(` FormalParameters[+Yield, ~Await] `)` `{` GeneratorBody `}` GeneratorBody : - FunctionBody[+Yield] + FunctionBody[+Yield, ~Await] - YieldExpression[In] : + YieldExpression[In, Await] : `yield` - `yield` [no LineTerminator here] AssignmentExpression[?In, +Yield] - `yield` [no LineTerminator here] `*` AssignmentExpression[?In, +Yield] + `yield` [no LineTerminator here] AssignmentExpression[?In, +Yield, ?Await] + `yield` [no LineTerminator here] `*` AssignmentExpression[?In, +Yield, ?Await]

The syntactic context immediately following `yield` requires use of the |InputElementRegExpOrTemplateTail| lexical goal.

@@ -18560,10 +18627,11 @@

Static Semantics: PropName

Runtime Semantics: EvaluateBody

-

With parameter _functionObject_.

+

With parameter _functionObject_ and List _argumentsList_.

GeneratorBody : FunctionBody + 1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_). 1. Let _G_ be ? OrdinaryCreateFromConstructor(_functionObject_, `"%GeneratorPrototype%"`, « [[GeneratorState]], [[GeneratorContext]] »). 1. Perform GeneratorStart(_G_, |FunctionBody|). 1. Return Completion{[[Type]]: ~return~, [[Value]]: _G_, [[Target]]: ~empty~}. @@ -18707,29 +18775,29 @@

Runtime Semantics: Evaluation

Class Definitions

Syntax

- ClassDeclaration[Yield, Default] : - `class` BindingIdentifier[?Yield] ClassTail[?Yield] - [+Default] `class` ClassTail[?Yield] + ClassDeclaration[Yield, Await, Default] : + `class` BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] `class` ClassTail[?Yield, ?Await] - ClassExpression[Yield] : - `class` BindingIdentifier[?Yield]? ClassTail[?Yield] + ClassExpression[Yield, Await] : + `class` BindingIdentifier[?Yield, ?Await]? ClassTail[?Yield, ?Await] - ClassTail[Yield] : - ClassHeritage[?Yield]? `{` ClassBody[?Yield]? `}` + ClassTail[Yield, Await] : + ClassHeritage[?Yield, ?Await]? `{` ClassBody[?Yield, ?Await]? `}` - ClassHeritage[Yield] : - `extends` LeftHandSideExpression[?Yield] + ClassHeritage[Yield, Await] : + `extends` LeftHandSideExpression[?Yield, ?Await] - ClassBody[Yield] : - ClassElementList[?Yield] + ClassBody[Yield, Await] : + ClassElementList[?Yield, ?Await] - ClassElementList[Yield] : - ClassElement[?Yield] - ClassElementList[?Yield] ClassElement[?Yield] + ClassElementList[Yield, Await] : + ClassElement[?Yield, ?Await] + ClassElementList[?Yield, ?Await] ClassElement[?Yield, ?Await] - ClassElement[Yield] : - MethodDefinition[?Yield] - `static` MethodDefinition[?Yield] + ClassElement[Yield, Await] : + MethodDefinition[?Yield, ?Await] + `static` MethodDefinition[?Yield, ?Await] `;` @@ -18995,11 +19063,11 @@

Runtime Semantics: ClassDefinitionEvaluation

1. If |ClassHeritage_opt| is present and _protoParent_ is not *null*, then 1. Let _constructor_ be the result of parsing the source text
constructor(... args){ super (...args);}
- using the syntactic grammar with the goal symbol |MethodDefinition[~Yield]|. + using the syntactic grammar with the goal symbol |MethodDefinition[~Yield, ~Await]|. 1. Else, 1. Let _constructor_ be the result of parsing the source text
constructor( ){ }
- using the syntactic grammar with the goal symbol |MethodDefinition[~Yield]|. + using the syntactic grammar with the goal symbol |MethodDefinition[~Yield, ~Await]|. 1. Set the running execution context's LexicalEnvironment to _classScope_. 1. Let _constructorInfo_ be the result of performing DefineMethod for _constructor_ with arguments _proto_ and _constructorParent_ as the optional _functionPrototype_ argument. 1. Assert: _constructorInfo_ is not an abrupt completion. @@ -19078,6 +19146,546 @@

Runtime Semantics: Evaluation

+ +

Async Function Definitions

+

Syntax

+ + AsyncFunctionDeclaration[Yield, Await, Default] : + `async` [no LineTerminator here] `function` BindingIdentifier[?Yield, ?Await] `(` FormalParameters[?Yield, ?Await] `)` `{` AsyncFunctionBody `}` + [+Default] `async` [no LineTerminator here] `function` `(` FormalParameters[?Yield, ?Await] `)` `{` AsyncFunctionBody `}` + + AsyncFunctionExpression : + `async` [no LineTerminator here] `function` `(` FormalParameters[~Yield, +Await] `)` `{` AsyncFunctionBody `}` + `async` [no LineTerminator here] `function` BindingIdentifier[~Yield, +Await] `(` FormalParameters[~Yield, +Await] `)` `{` AsyncFunctionBody `}` + + AsyncMethod[Yield, Await] : + `async` [no LineTerminator here] PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[?Yield, +Await] `)` `{` AsyncFunctionBody `}` + + AsyncFunctionBody : + FunctionBody[~Yield, +Await] + + AwaitExpression[Yield] : + `await` UnaryExpression[?Yield, +Await] + + + +

`await` is parsed as an |AwaitExpression| when the [Await] parameter in 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.
  • +
+

When |Module| is the syntatic 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|.
  • +
+
+ + +

Unlike |YieldExpression|, it is a Syntax Error to omit the operand of an |AwaitExpression|. You must await something.

+
+ + +

Static Semantics: Early Errors

+ + AsyncMethod : `async` [no LineTerminator here] PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + +
    +
  • It is a Syntax Error if ContainsUseStrict of |AsyncFunctionBody| is *true* and IsSimpleParameterList of |UniqueFormalParameters| is *false*.
  • +
  • It is a Syntax Error if HasDirectSuper of |AsyncMethod| is *true*.
  • +
  • It is a Syntax Error if |UniqueFormalParameters| Contains |AwaitExpression| is *true*.
  • +
  • It is a Syntax Error if any element of the BoundNames of |UniqueFormalParameters| also occurs in the LexicallyDeclaredNames of |AsyncFunctionBody|
  • +
+ + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncFunctionExpression : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncFunctionExpression : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + +
    +
  • It is a Syntax Error if ContainsUseStrict of |AsyncFunctionBody| is *true* and IsSimpleParameterList of |FormalParameters| is *false*.
  • +
  • It is a Syntax Error if |FormalParameters| Contains |AwaitExpression| is *true*.
  • +
  • If the source code matching this production is strict code, the Early Error rules for |UniqueFormalParameters| : |FormalParameters| are applied.
  • +
  • If the source code matching this production is strict code, it is a Syntax Error if |BindingIdentifier| is the |IdentifierName| `eval` or the |IdentifierName| `arguments`.
  • +
  • It is a Syntax Error if any element of the BoundNames of |FormalParameters| also occurs in the LexicallyDeclaredNames of |AsyncFunctionBody|.
  • +
  • It is a Syntax Error if |FormalParameters| contains |SuperProperty| is *true*.
  • +
  • It is a Syntax Error if |AsyncFunctionBody| contains |SuperProperty| is *true*.
  • +
  • It is a Syntax Error if |FormalParameters| contains |SuperCall| is *true*.
  • +
  • It is a Syntax Error if |AsyncFunctionBody| contains |SuperCall| is *true*.
  • +
+
+ + +

Static Semantics: BoundNames

+ + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return the BoundNames of |BindingIdentifier|. + + + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 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_.

+ + AsyncMethod : `async` [no LineTerminator here] PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. + +
+ + +

Static Semantics: Contains

+

With parameter _symbol_.

+ + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncFunctionExpression : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncFunctionExpression : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return *false*. + +
+ + +

Static Semantics: HasDirectSuper

+ + AsyncMethod : `async` [no LineTerminator here] PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. If |UniqueFormalParameters| Contains |SuperCall| is *true*, return *true*. + 2. Return |AsyncFunctionBody| Contains |SuperCall|. + +
+ + +

Static Semantics: HasName

+ + AsyncFunctionExpression : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return *false*. + + + AsyncFunctionExpression : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return *true*. + +
+ + +

Static Semantics: IsConstantDeclaration

+ + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return *false*. + +
+ + +

Static Semantics: IsFunctionDefinition

+ + AsyncFunctionExpression : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncFunctionExpression : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return *true*. + +
+ + +

Static Semantics: PropName

+ + AsyncMethod : `async` [no LineTerminator here] PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return PropName of |PropertyName|. + +
+ + +

Runtime Semantics: InstantiateFunctionObject

+

With parameter _scope_.

+ + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. If the function code for |AsyncFunctionDeclaration| is strict mode code, let _strict_ be *true*. Otherwise, let _strict_ be *false*. + 2. Let _name_ be StringValue of |BindingIdentifier|. + 3. Let _F_ be ! AsyncFunctionCreate(~Normal~, |FormalParameters|, |AsyncFunctionBody|, _scope_, _strict_). + 4. Perform ! SetFunctionName(_F_, _name_). + 1. Set _F_.[[SourceText]] to the source text matched by |AsyncFunctionDeclaration|. + 5. Return _F_. + + + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. If the function code for |AsyncFunctionDeclaration| is strict mode code, let _strict_ be *true*. Otherwise, let _strict_ be *false*. + 2. Let _F_ be ! AsyncFunctionCreate(~Normal~, |FormalParameters|, |AsyncFunctionBody|, _scope_, _strict_). + 3. Perform ! SetFunctionName(_F_, `"default"`). + 1. Set _F_.[[SourceText]] to the source text matched by |AsyncFunctionDeclaration|. + 4. Return _F_. + +
+ + +

Runtime Semantics: EvaluateBody

+

With parameters _functionObject_ and List _argumentsList_.

+ + AsyncFunctionBody : FunctionBody + + + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. Let _declResult_ be FunctionDeclarationInstantiation(_functionObject_, _argumentsList_). + 1. If _declResult_ is not an abrupt completion, then + 1. Perform ! AsyncFunctionStart(_promiseCapability_, _FunctionBody_). + 1. Else _declResult_ is an abrupt completion, + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, «_declResult_.[[value]]»). + 1. Return Completion{[[type]]: ~return~, [[value]]: _promiseCapability_.[[Promise]], [[target]]: ~empty~}. + +
+ + +

Runtime Semantics: PropertyDefinitionEvaluation

+

With parameters _object_ and _enumerable_.

+ + AsyncMethod : `async` [no LineTerminator here] PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Let _propKey_ be the result of evaluating |PropertyName|. + 1. ReturnIfAbrupt(_propKey_). + 1. If the function code for this |AsyncMethod| 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 ! AsyncFunctionCreate(~Method~, |UniqueFormalParameters|, |AsyncFunctionBody|, _scope_, _strict_). + 1. Perform ! MakeMethod(_closure_, _object_). + 1. Perform ! SetFunctionName(_closure_, _propKey_). + 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncMethod|. + 1. Let _desc_ be the PropertyDescriptor{[[Value]]: _closure_, [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true*}. + 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_). + +
+ +

Runtime Semantics: Evaluation

+ + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return NormalCompletion(~empty~). + + + + AsyncFunctionDeclaration : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return NormalCompletion(~empty~). + + + + AsyncFunctionExpression : `async` [no LineTerminator here] `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. If the function code for |AsyncFunctionExpression| 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 ! AsyncFunctionCreate(~Normal~, |FormalParameters|, |AsyncFunctionBody|, _scope_, _strict_). + 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncFunctionExpression|. + 1. Return _closure_. + + + + AsyncFunctionExpression : `async` [no LineTerminator here] `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. If the function code for |AsyncFunctionExpression| 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 _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 ! AsyncFunctionCreate(~Normal~, |FormalParameters|, |AsyncFunctionBody|, _funcEnv_, _strict_). + 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncFunctionExpression|. + 1. Perform ! SetFunctionName(_closure_, _name_). + 1. Perform ! _envRec_.InitializeBinding(_name_, _closure_). + 1. Return _closure_. + + + + AwaitExpression : `await` UnaryExpression + + + 1. Let _exprRef_ be the result of evaluating |UnaryExpression|. + 1. Let _value_ be ? GetValue(_exprRef_). + 1. Return ? AsyncFunctionAwait(_value_). + +
+
+ + +

Async Arrow Function Definitions

+

Syntax

+ + AsyncArrowFunction[In, Yield, Await] : + `async` [no LineTerminator here] AsyncArrowBindingIdentifier[?Yield] [no LineTerminator here] `=>` AsyncConciseBody[?In, ?Yield] + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] [no LineTerminator here] `=>` AsyncConciseBody[?In, ?Yield] #callcover + + AsyncConciseBody[In, Yield] : + [lookahead != `{`] AssignmentExpression[?In, ?Yield, +Await] + `{` AsyncFunctionBody `}` + + AsyncArrowBindingIdentifier[Yield] : + BindingIdentifier[?Yield, +Await] + + CoverCallExpressionAndAsyncArrowHead[Yield, Await] : + MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] + +

Supplemental Syntax

+

When processing the production AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead [no LineTerminator here] `=>` AsyncConciseBody the interpretation of |CoverCallExpressionAndAsyncArrowHead| is refined using the following grammar:

+ + + AsyncArrowHead : + `async` [no LineTerminator here] ArrowFormalParameters[+Yield, +Await] + + + +

Static Semantics: Early Errors

+ + AsyncArrowFunction : `async` [no LineTerminator here] AsyncArrowBindingIdentifier [no LineTerminator here] `=>` AsyncConciseBody + +
    +
  • It is a Syntax Error if ContainsUseStrict of |AsyncConciseBody| is *true* and IsSimpleParameterList of |ArrowParameters| is *false*.
  • +
  • It is a Syntax Error if any element of the BoundNames of |AsyncArrowBindingIdentifier| also occurs in the LexicallyDeclaredNames of |AsyncConciseBody|.
  • +
+ + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead [no LineTerminator here] `=>` AsyncConciseBody + +
    +
  • It is a Syntax Error if |CoverCallExpressionAndAsyncArrowHead| Contains |YieldExpression| is *true*.
  • +
  • It is a Syntax Error if |CoverCallExpressionAndAsyncArrowHead| Contains |AwaitExpression| is *true*.
  • +
  • It is a Syntax Error if any element of the BoundNames of |CoverCallExpressionAndAsyncArrowHead| also occurs in the LexicallyDeclaredNames of |AsyncConciseBody|.
  • +
  • It is a Syntax Error if the lexical token sequence matched by |CoverCallExpressionAndAsyncArrowHead| cannot be parsed with no tokens left over using |AsyncArrowHead| as the goal symbol.
  • +
  • All Early Error rules for |AsyncArrowHead| and its derived productions apply to CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|.
  • +
+
+ + +

Static Semantics: CoveredAsyncArrowHead

+

+ + CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments + + + 1. Return the result of parsing the lexical token stream matched by |CoverCallExpressionAndAsyncArrowHead| using |AsyncArrowHead| as the goal symbol. + +
+ + +

Static Semantics: BoundNames

+ + CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments + + + 1. Let _head_ be CoveredAsyncFunctionHead of |CoverCallExpressionAndAsyncArrowHead|. + 1. Return the BoundNames of _head_. + +
+ + +

Static Semantics: Contains

+

With parameter _symbol_.

+ + AsyncArrowFunction : `async` [no LineTerminator here] AsyncArrowBindingIdentifier [no LineTerminator here] `=>` AsyncConciseBody + + + 1. If _symbol_ is not one of |NewTarget|, |SuperProperty|, |SuperCall|, `super`, or `this`, return *false*. + 1. Return |AsyncConciseBody| Contains _symbol_. + + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead [no LineTerminator here] `=>` AsyncConciseBody + + + 1. If _symbol_ is not one of |NewTarget|, |SuperProperty|, |SuperCall|, `super`, or `this`, return *false*. + 2. Let _head_ be CoveredAsyncFunctionHead of |CoverCallExpressionAndAsyncArrowHead|. + 3. If _head_ Contains _symbol_ is *true*, return *true*. + 4. Return |AsyncConciseBody| Contains _symbol_. + + Normally, Contains does not look inside most function forms. However, Contains is used to detect `new.target`, `this`, and `super` usage within an AsyncArrowFunction. +
+ + +

Static Semantics: ContainsExpression

+ + AsyncArrowBindingIdentifier : BindingIdentifier + + + 1. Return *false*. + +
+ + +

Static Semantics: ExpectedArgumentCount

+ + AsyncArrowBindingIdentifier : BindingIdentifier + + + 1. Return 1. + +
+ + +

Static Semantics: HasName

+ + AsyncArrowFunction : `async` [no LineTerminator here] AsyncArrowBindingIdentifier [no LineTerminator here] `=>` AsyncConciseBody + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead [no LineTerminator here] `=>` AsyncConciseBody + + + 1. Return *false*. + +
+ + +

Static Semantics: IsSimpleParameterList

+ + AsyncArrowBindingIdentifier[Yield] : BindingIdentifier[?Yield, +Await] + + + 1. Return *true*. + +
+ + +

Static Semantics: LexicallyDeclaredNames

+ + AsyncConciseBody : [lookahead != `{`] AssignmentExpression + + + 1. Return a new empty List. + +
+ + +

Static Semantics: LexicallyScopedDeclarations

+ + AsyncConciseBody : [lookahead != `{`] AssignmentExpression + + + 1. Return a new empty List. + +
+ + +

Static Semantics: VarDeclaredNames

+ + AsyncConciseBody : [lookahead != `{`] AssignmentExpression + + + 1. Return a new empty List. + +
+ + +

Static Semantics: VarScopedDeclarations

+ + AsyncConciseBody : [lookahead != `{`] AssignmentExpression + + + 1. Return a new empty List. + +
+ + +

Runtime Semantics: IteratorBindingInitialization

+

With parameters _iteratorRecord_ and _environment_.

+ + AsyncArrowBindingIdentifier : BindingIdentifier + + + 1. Assert: _iteratorRecord_.[[done]] is *false*. + 1. Let _next_ be ? IteratorStep(_iteratorRecord_.[[iterator]]). + 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[done]] to *true*. + 1. ReturnIfAbrupt(_next_). + 1. If _next_ is *false*, set _iteratorRecord_.[[done]] to *true*. + 1. Else, + 1. Let _v_ be ? IteratorValue(_next_). + 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[done]] to *true*. + 1. ReturnIfAbrupt(_v_). + 1. If _iteratorRecord_.[[done]] is *true*, let _v_ be *undefined*. + 1. Return the result of performing BindingInitialization for |BindingIdentifier| using _v_ and _environment_ as the arguments. + +
+ + +

Runtime Semantics: EvaluateBody

+

With parameter _functionObject_ and List _argumentsList_.

+ + AsyncConciseBody : [lookahead != `{`] AssignmentExpression + + + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. Let _declResult_ be ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_). + 1. If _declResult_ is not an abrupt completion, then + 1. Perform ! AsyncFunctionStart(_promiseCapability_, _AssignmentExpression_). + 1. Else _declResult_ is an abrupt completion, + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, «_declResult_.[[value]]»). + 1. Return Completion{[[type]]: ~return~, [[value]]: _promiseCapability_.[[Promise]], [[target]]: ~empty~}. + + + AsyncConciseBody : `{` AsyncFunctionBody `}` + + + 1. Return the result of EvaluateBody of |AsyncFunctionBody| passing _functionObject_ and _argumentsList_ as the arguments. + +
+ + +

Runtime Semantics: Evaluation

+ + AsyncArrowFunction : `async` [no LineTerminator here] AsyncArrowBindingIdentifier [no LineTerminator here] `=>` AsyncConciseBody + + + 1. If the function code for this |AsyncArrowFunction| is strict mode code, let _strict_ be *true*. Otherwise, let _strict_ be *false*. + 2. Let _scope_ be the LexicalEnvironment of the running execution context. + 3. Let _parameters_ be |AsyncArrowBindingIdentifier|. + 4. Let _closure_ be ! AsyncFunctionCreate(~Arrow~, _parameters_, |AsyncConciseBody|, _scope_, _strict_). + 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncArrowFunction|. + 5. Return _closure_. + + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead [no LineTerminator here] `=>` AsyncConciseBody + + + 1. If the function code for this |AsyncArrowFunction| is strict mode code, let _strict_ be *true*. Otherwise, let _strict_ be *false*. + 2. Let _scope_ be the LexicalEnvironment of the running execution context. + 3. Let _head_ be CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|. + 4. Let _parameters_ be the |ArrowFormalParameters| of _head_. + 5. Let _closure_ be ! AsyncFunctionCreate(~Arrow~, _parameters_, |AsyncConciseBody|, _scope_, _strict_). + 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncArrowFunction|. + 6. Return _closure_. + +
+
+

Tail Position Calls

@@ -19242,6 +19850,7 @@

Expression Rules

AssignmentExpression : YieldExpression ArrowFunction + AsyncArrowFunction LeftHandSideExpression `=` AssignmentExpression LeftHandSideExpression AssignmentOperator AssignmentExpression @@ -19318,6 +19927,7 @@

Expression Rules

FunctionExpression ClassExpression GeneratorExpression + AsyncFunctionExpression RegularExpressionLiteral TemplateLiteral @@ -19348,7 +19958,7 @@

Expression Rules

CallExpression : - MemberExpression Arguments + CoverCallExpressionAndAsyncArrowHead CallExpression Arguments CallExpression TemplateLiteral @@ -19410,7 +20020,7 @@

Syntax

ScriptBody? ScriptBody : - StatementList[~Yield, ~Return] + StatementList[~Yield, ~Await, ~Return] @@ -19723,7 +20333,7 @@

Syntax

ModuleItem : ImportDeclaration ExportDeclaration - StatementListItem[~Yield, ~Return] + StatementListItem[~Yield, ~Await, ~Return] @@ -20995,7 +21605,7 @@

Syntax

StringLiteral ImportedBinding : - BindingIdentifier[~Yield] + BindingIdentifier[~Yield, ~Await] @@ -21141,11 +21751,11 @@

Syntax

`export` `*` FromClause `;` `export` ExportClause FromClause `;` `export` ExportClause `;` - `export` VariableStatement[~Yield] - `export` Declaration[~Yield] - `export` `default` HoistableDeclaration[~Yield, +Default] - `export` `default` ClassDeclaration[~Yield, +Default] - `export` `default` [lookahead <! {`function`, `class`}] AssignmentExpression[+In, ~Yield] `;` + `export` VariableStatement[~Yield, ~Await] + `export` Declaration[~Yield, ~Await] + `export` `default` HoistableDeclaration[~Yield, ~Await, +Default] + `export` `default` ClassDeclaration[~Yield, ~Await, +Default] + `export` `default` [lookahead <! {`function`, `async` [no |LineTerminator| here] `function`, `class`}] AssignmentExpression[+In, ~Yield, ~Await] `;` ExportClause : `{` `}` @@ -21605,7 +22215,7 @@

Forbidden Extensions

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

  • - Other than as defined in this specification, ECMAScript Function objects defined using syntactic constructors in strict mode code must not be created with own properties named `"caller"` or `"arguments"` other than those that are created by applying the AddRestrictedFunctionProperties abstract operation to the function. Such own properties also must not be created for function objects defined using an |ArrowFunction|, |MethodDefinition|, |GeneratorDeclaration|, |GeneratorExpression|, |ClassDeclaration|, or |ClassExpression| 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, and functions created using the `bind` method also must not be created with such own properties. + Other than as defined in this specification, ECMAScript Function objects defined using syntactic constructors in strict mode code must not be created with own properties named `"caller"` or `"arguments"` other than those that are created by applying the AddRestrictedFunctionProperties abstract operation to the function. 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, and functions created using the `bind` method also must not be created with such own properties.
  • If an implementation extends non-strict or built-in function objects 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. @@ -23021,7 +23631,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 instances 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` subclass.

    +

    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 instances 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.

    @@ -23047,17 +23657,22 @@

    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"` or `"generator"`, 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"`, or `"async"`, and _args_ is a List containing the actual argument values that were passed to _constructor_. The following steps are taken:

    1. If _newTarget_ is *undefined*, let _newTarget_ be _constructor_. 1. If _kind_ is `"normal"`, then - 1. Let _goal_ be the grammar symbol |FunctionBody[~Yield]|. - 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[~Yield]|. + 1. Let _goal_ be the grammar symbol |FunctionBody[~Yield, ~Await]|. + 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[~Yield, ~Await]|. 1. Let _fallbackProto_ be `"%FunctionPrototype%"`. - 1. Else, + 1. Else if _kind_ is `"generator"`, then 1. Let _goal_ be the grammar symbol |GeneratorBody|. - 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[+Yield]|. + 1. Let _parameterGoal_ be the grammar symbol |FormalParameters[+Yield, ~Await]|. 1. Let _fallbackProto_ be `"%Generator%"`. + 1. Else, + 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. 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. @@ -23085,6 +23700,8 @@

    Runtime Semantics: CreateDynamicFunction(_constructor_, _newTarget_, _kind_, 1. If _parameters_ Contains |SuperProperty| is *true*, throw a *SyntaxError* exception. 1. If _kind_ is `"generator"`, then 1. If _parameters_ Contains |YieldExpression| is *true*, throw a *SyntaxError* exception. + 1. If _kind_ is `"async"`, 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. 1. Let _proto_ be ? GetPrototypeFromConstructor(_newTarget_, _fallbackProto_). @@ -23096,6 +23713,7 @@

    Runtime Semantics: CreateDynamicFunction(_constructor_, _newTarget_, _kind_, 1. Let _prototype_ be ObjectCreate(%GeneratorPrototype%). 1. Perform DefinePropertyOrThrow(_F_, `"prototype"`, PropertyDescriptor{[[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false*}). 1. Else, perform MakeConstructor(_F_). + 1. NOTE: Async functions are not constructable and do not have a prototype property. 1. Perform SetFunctionName(_F_, `"anonymous"`). 1. Return _F_. @@ -34945,6 +35563,190 @@

    Properties of Promise Instances

    + + +

    AsyncFunction Objects

    + +

    The AsyncFunction Constructor

    + +

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

    + +

    The `AsyncFunction` 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 AsyncFunction behaviour must include a super call to the AsyncFunction constructor to create and initialize a subclass instances with the internal slots necessary for built-in async function behaviour.

    + + +

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

    + +

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

    + +

    When the `AsyncFunction` 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. + 2. Let _args_ be the _argumentsList_ that was passed to this function by [[Call]] or [[Construct]]. + 3. Return CreateDynamicFunction(_C_, NewTarget, `"async"`, _args_). + + + See note for 19.2.1.1 +
    +
    + +

    Properties of the AsyncFunction Constructor

    + +

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

    + +

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

    + +

    The value of the *name* property of the AsyncFunction is "AsyncFunction".

    + +

    The AsyncFunction constructor has the following properties:

    + + +

    AsyncFunction.length

    +

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

    +
    + + +

    AsyncFunction.prototype

    +

    The initial value of `AsyncFunction.prototype` is the intrinsic object %AsyncFunctionPrototype%.

    + +

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

    +
    +
    + +

    Properties of the AsyncFunction Prototype Object

    +

    The AsyncFunction prototype object is an ordinary object. In addition to being the value of the prototype property of the %AsyncFunction% intrinsic, it is the %AsyncFunctionPrototype% intrinsic.

    + +

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

    + +

    The AsyncFunction prototype object does not have a prototype property.

    + Presumably this could be Promise.prototype but I'm not sure this has any value? + + + +

    AsyncFunction.prototype.constructor

    + +

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

    + +

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

    +
    + + +

    AsyncFunction.prototype [ @@toStringTag ]

    + +

    The initial value of the @@toStringTag property is the string value "AsyncFunction".

    + +

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

    +
    +
    + + +

    AsyncFunction Instances

    + +

    Every AsyncFunction 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 `"normal"`. AsyncFunction instances are not constructors and do not have a [[Construct]] internal slot. AsyncFunction instances do not have a prototype property as they are not constructable.

    +

    Each AsyncFunction 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 AsyncFunction. However, the language permits the function to be invoked with some other number of arguments. The behaviour of an AsyncFunction 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 19.2.4.2 also applies to AsyncFunction instances.

    +
    +
    + + +

    Async Functions Abstract Operations

    + + +

    AsyncFunctionCreate ( _kind_, _parameters_, _body_, _Scope_, _Strict_ )

    +

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

    + + 1. Let _functionPrototype_ be the intrinsic object %AsyncFunctionPrototype%. + 2. Let _F_ be ! FunctionAllocate(_functionPrototype_, _Strict_, `"non-constructor"`). + 3. Return ! FunctionInitialize(_F_, _kind_, _parameters_, _body_, _Scope_). + +
    + + +

    AsyncFunctionStart ( _promiseCapability_, _asyncFunctionBody_ )

    + + 1. Let _runningContext_ be the running execution context. + 1. Let _asyncContext_ be a copy of _runningContext_. + 1. Set the code evaluation state of _asyncContext_ such that when evaluation is resumed for that execution context the following steps will be performed: + 1. Let _result_ be the result of evaluating _asyncFunctionBody_. + 1. Assert: If we return here, the async function either threw an exception or performed an implicit or explicit return; all awaiting is done. + 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. If _result_.[[type]] is ~normal~, then + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, «*undefined*»). + 1. Else if _result_.[[type]] is ~return~, then + 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, «_result_.[[value]]»). + 1. Else, + 1. Assert: _result_.[[type]] is ~throw~. + 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, «_result_.[[value]]»). + 1. Return. + 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.7 above. + 1. Return. + +
    + + +

    AsyncFunctionAwait ( _value_ )

    + + 1. Let _asyncContext_ be the running execution context. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. Let _resolveResult_ be ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _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_.[[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. Return. + + + The return value of this abstract operation is unused. The interesting return is that of _resumptionValue_ being returned to the |AwaitExpression| production that originally called this abstract operation. +
    + + +

    AsyncFunction Awaited Fulfilled

    +

    Function _F_ is called with the parameter _value_. _F_ has an internal slot named [[AsyncContext]] which is the execution context that will be restored when _F_ is called.

    + + 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

    +

    Function _F_ is called with the parameter _reason_. _F_ has an internal slot named [[AsyncContext]] which is the execution context that will be restored when _F_ is called.

    + + 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_). + +
    +
    +
    @@ -35301,6 +36103,7 @@

    Expressions

    + @@ -35329,6 +36132,11 @@

    Expressions

    + +

    When processing the production the interpretation of |CoverCallExpressionAndAsyncArrowHead| is refined using the following grammar:

    + +

     

    + @@ -35436,6 +36244,11 @@

    Functions and Classes

    When the production is recognized the following grammar is used to refine the interpretation of |CoverParenthesizedExpressionAndArrowParameterList|:

     

    + + +

    When the production is recognized the following grammar is used to refine the interpretation of |CoverParenthesizedExpressionAndArrowParameterList|:

    + +

     

    @@ -35443,6 +36256,11 @@

    Functions and Classes

    + + + + + @@ -36615,13 +37433,13 @@

    Changes to BlockDeclarationInstantiation

    FunctionDeclarations in IfStatement Statement Clauses

    The following augments the |IfStatement| production in :

    - IfStatement[Yield, Return] : - `if` `(` Expression[+In, ?Yield] `)` FunctionDeclaration[?Yield, ~Default] `else` Statement[?Yield, ?Return] - `if` `(` Expression[+In, ?Yield] `)` Statement[?Yield, ?Return] `else` FunctionDeclaration[?Yield, ~Default] - `if` `(` Expression[+In, ?Yield] `)` FunctionDeclaration[?Yield, ~Default] `else` FunctionDeclaration[?Yield, ~Default] - `if` `(` Expression[+In, ?Yield] `)` FunctionDeclaration[?Yield, ~Default] + IfStatement[Yield, Await, Return] : + `if` `(` Expression[+In, ?Yield, ?Await] `)` FunctionDeclaration[?Yield, ?Await, ~Default] `else` Statement[?Yield, ?Await, ?Return] + `if` `(` Expression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return] `else` FunctionDeclaration[?Yield, ?Await, ~Default] + `if` `(` Expression[+In, ?Yield, ?Await] `)` FunctionDeclaration[?Yield, ?Await, ~Default] `else` FunctionDeclaration[?Yield, ?Await, ~Default] + `if` `(` Expression[+In, ?Yield, ?Await] `)` FunctionDeclaration[?Yield, ?Await, ~Default] -

    This production only applies when parsing non-strict code. Code matching this production is processed as if each matching occurrence of |FunctionDeclaration[?Yield, ~Default]| was the sole |StatementListItem| of a |BlockStatement| occupying that position in the source code. The semantics of such a synthetic |BlockStatement| includes the web legacy compatibility semantics specified in .

    +

    This production only applies when parsing non-strict code. Code matching this production is processed as if each matching occurrence of |FunctionDeclaration[?Yield, ?Await, ~Default]| was the sole |StatementListItem| of a |BlockStatement| occupying that position in the source code. The semantics of such a synthetic |BlockStatement| includes the web legacy compatibility semantics specified in .

    @@ -36660,8 +37478,8 @@

    VariableStatements in Catch Blocks

    Initializers in ForIn Statement Heads

    The following augments the |IterationStatement| production in :

    - IterationStatement[Yield, Return] : - `for` `(` `var` BindingIdentifier[?Yield] Initializer[~In, ?Yield] `in` Expression[+In, ?Yield] `)` Statement[?Yield, ?Return] + IterationStatement[Yield, Await, Return] : + `for` `(` `var` BindingIdentifier[?Yield, ?Await] Initializer[~In, ?Yield, ?Await] `in` Expression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]

    This production only applies when parsing non-strict code.

    The static semantics of ContainsDuplicateLabels in are augmented with the following: