8 Syntax-Directed Operations

In addition to those defined in this section, specialized syntax-directed operations are defined throughout this specification.

8.1 Runtime Semantics: Evaluation

The syntax-directed operation Evaluation takes no arguments and returns a Completion Record.

Note
The definitions for this operation are distributed over the "ECMAScript Language" sections of this specification. Each definition appears after the defining occurrence of the relevant productions.

8.2 Scope Analysis

8.2.1 Static Semantics: BoundNames

The syntax-directed operation BoundNames takes no arguments and returns a List of Strings.

Note

"*default*" is used within this specification as a synthetic name for a module's default export when it does not have another name. An entry in the module's [[Environment]] is created with that name and holds the corresponding value, and resolving the export named "default" by calling ResolveExport ( exportName [ , resolveSet ] ) for the module will return a ResolvedBinding Record whose [[BindingName]] is "*default*", which will then resolve in the module's [[Environment]] to the above-mentioned value. This is done only for ease of specification, so that anonymous default exports can be resolved like any other export. This "*default*" string is never accessible to ECMAScript code or to the module linking algorithm.

It is defined piecewise over the following productions:

BindingIdentifier : Identifier
  1. Return a List whose sole element is the StringValue of Identifier.
BindingIdentifier : yield
  1. Return « "yield" ».
BindingIdentifier : await
  1. Return « "await" ».
LexicalDeclaration : LetOrConst BindingList ;
  1. Return the BoundNames of BindingList.
BindingList : BindingList , LexicalBinding
  1. Let names1 be the BoundNames of BindingList.
  2. Let names2 be the BoundNames of LexicalBinding.
  3. Return the list-concatenation of names1 and names2.
LexicalBinding : BindingIdentifier Initializeropt
  1. Return the BoundNames of BindingIdentifier.
LexicalBinding : BindingPattern Initializer
  1. Return the BoundNames of BindingPattern.
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. Let names1 be the BoundNames of VariableDeclarationList.
  2. Let names2 be the BoundNames of VariableDeclaration.
  3. Return the list-concatenation of names1 and names2.
VariableDeclaration : BindingIdentifier Initializeropt
  1. Return the BoundNames of BindingIdentifier.
VariableDeclaration : BindingPattern Initializer
  1. Return the BoundNames of BindingPattern.
ObjectBindingPattern : { }
  1. Return a new empty List.
ObjectBindingPattern : { BindingPropertyList , BindingRestProperty }
  1. Let names1 be the BoundNames of BindingPropertyList.
  2. Let names2 be the BoundNames of BindingRestProperty.
  3. Return the list-concatenation of names1 and names2.
ArrayBindingPattern : [ Elisionopt ]
  1. Return a new empty List.
ArrayBindingPattern : [ Elisionopt BindingRestElement ]
  1. Return the BoundNames of BindingRestElement.
ArrayBindingPattern : [ BindingElementList , Elisionopt ]
  1. Return the BoundNames of BindingElementList.
ArrayBindingPattern : [ BindingElementList , Elisionopt BindingRestElement ]
  1. Let names1 be the BoundNames of BindingElementList.
  2. Let names2 be the BoundNames of BindingRestElement.
  3. Return the list-concatenation of names1 and names2.
BindingPropertyList : BindingPropertyList , BindingProperty
  1. Let names1 be the BoundNames of BindingPropertyList.
  2. Let names2 be the BoundNames of BindingProperty.
  3. Return the list-concatenation of names1 and names2.
BindingElementList : BindingElementList , BindingElisionElement
  1. Let names1 be the BoundNames of BindingElementList.
  2. Let names2 be the BoundNames of BindingElisionElement.
  3. Return the list-concatenation of names1 and names2.
BindingElisionElement : Elisionopt BindingElement
  1. Return the BoundNames of BindingElement.
BindingProperty : PropertyName : BindingElement
  1. Return the BoundNames of BindingElement.
SingleNameBinding : BindingIdentifier Initializeropt
  1. Return the BoundNames of BindingIdentifier.
BindingElement : BindingPattern Initializeropt
  1. Return the BoundNames of BindingPattern.
ForDeclaration : LetOrConst ForBinding
  1. Return the BoundNames of ForBinding.
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody }
  1. Return the BoundNames of BindingIdentifier.
FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
  1. Return « "*default*" ».
FormalParameters : [empty]
  1. Return a new empty List.
FormalParameters : FormalParameterList , FunctionRestParameter
  1. Let names1 be the BoundNames of FormalParameterList.
  2. Let names2 be the BoundNames of FunctionRestParameter.
  3. Return the list-concatenation of names1 and names2.
FormalParameterList : FormalParameterList , FormalParameter
  1. Let names1 be the BoundNames of FormalParameterList.
  2. Let names2 be the BoundNames of FormalParameter.
  3. Return the list-concatenation of names1 and names2.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. Let formals be the ArrowFormalParameters that is covered by CoverParenthesizedExpressionAndArrowParameterList.
  2. Return the BoundNames of formals.
GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
  1. Return the BoundNames of BindingIdentifier.
GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
  1. Return « "*default*" ».
AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
  1. Return the BoundNames of BindingIdentifier.
AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. Return « "*default*" ».
ClassDeclaration : class BindingIdentifier ClassTail
  1. Return the BoundNames of BindingIdentifier.
ClassDeclaration : class ClassTail
  1. Return « "*default*" ».
AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
  1. Return the BoundNames of BindingIdentifier.
AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody }
  1. Return « "*default*" ».
CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments
  1. Let head be the AsyncArrowHead that is covered by CoverCallExpressionAndAsyncArrowHead.
  2. Return the BoundNames of head.
ImportDeclaration : import ImportClause FromClause ;
  1. Return the BoundNames of ImportClause.
ImportDeclaration : import ModuleSpecifier ;
  1. Return a new empty List.
ImportClause : ImportedDefaultBinding , NameSpaceImport
  1. Let names1 be the BoundNames of ImportedDefaultBinding.
  2. Let names2 be the BoundNames of NameSpaceImport.
  3. Return the list-concatenation of names1 and names2.
ImportClause : ImportedDefaultBinding , NamedImports
  1. Let names1 be the BoundNames of ImportedDefaultBinding.
  2. Let names2 be the BoundNames of NamedImports.
  3. Return the list-concatenation of names1 and names2.
NamedImports : { }
  1. Return a new empty List.
ImportsList : ImportsList , ImportSpecifier
  1. Let names1 be the BoundNames of ImportsList.
  2. Let names2 be the BoundNames of ImportSpecifier.
  3. Return the list-concatenation of names1 and names2.
ImportSpecifier : ModuleExportName as ImportedBinding
  1. Return the BoundNames of ImportedBinding.
ExportDeclaration : export ExportFromClause FromClause ; export NamedExports ;
  1. Return a new empty List.
ExportDeclaration : export VariableStatement
  1. Return the BoundNames of VariableStatement.
ExportDeclaration : export Declaration
  1. Return the BoundNames of Declaration.
ExportDeclaration : export default HoistableDeclaration
  1. Let declarationNames be the BoundNames of HoistableDeclaration.
  2. If declarationNames does not include the element "*default*", append "*default*" to declarationNames.
  3. Return declarationNames.
ExportDeclaration : export default ClassDeclaration
  1. Let declarationNames be the BoundNames of ClassDeclaration.
  2. If declarationNames does not include the element "*default*", append "*default*" to declarationNames.
  3. Return declarationNames.
ExportDeclaration : export default AssignmentExpression ;
  1. Return « "*default*" ».

8.2.2 Static Semantics: DeclarationPart

The syntax-directed operation DeclarationPart takes no arguments and returns a Parse Node. It is defined piecewise over the following productions:

HoistableDeclaration : FunctionDeclaration
  1. Return FunctionDeclaration.
HoistableDeclaration : GeneratorDeclaration
  1. Return GeneratorDeclaration.
HoistableDeclaration : AsyncFunctionDeclaration
  1. Return AsyncFunctionDeclaration.
HoistableDeclaration : AsyncGeneratorDeclaration
  1. Return AsyncGeneratorDeclaration.
Declaration : ClassDeclaration
  1. Return ClassDeclaration.
Declaration : LexicalDeclaration
  1. Return LexicalDeclaration.

8.2.3 Static Semantics: IsConstantDeclaration

The syntax-directed operation IsConstantDeclaration takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

LexicalDeclaration : LetOrConst BindingList ;
  1. Return IsConstantDeclaration of LetOrConst.
LetOrConst : let
  1. Return false.
LetOrConst : const
  1. Return true.
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody } GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody } AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody }
  1. Return false.
ClassDeclaration : class BindingIdentifier ClassTail class ClassTail
  1. Return false.
ExportDeclaration : export ExportFromClause FromClause ; export NamedExports ; export default AssignmentExpression ;
  1. Return false.
Note

It is not necessary to treat export default AssignmentExpression as a constant declaration because there is no syntax that permits assignment to the internal bound name used to reference a module's default object.

8.2.4 Static Semantics: LexicallyDeclaredNames

The syntax-directed operation LexicallyDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

Block : { }
  1. Return a new empty List.
StatementList : StatementList StatementListItem
  1. Let names1 be the LexicallyDeclaredNames of StatementList.
  2. Let names2 be the LexicallyDeclaredNames of StatementListItem.
  3. Return the list-concatenation of names1 and names2.
StatementListItem : Statement
  1. If Statement is Statement : LabelledStatement , return the LexicallyDeclaredNames of LabelledStatement.
  2. Return a new empty List.
StatementListItem : Declaration
  1. Return the BoundNames of Declaration.
CaseBlock : { }
  1. Return a new empty List.
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. If the first CaseClauses is present, let names1 be the LexicallyDeclaredNames of the first CaseClauses.
  2. Else, let names1 be a new empty List.
  3. Let names2 be the LexicallyDeclaredNames of DefaultClause.
  4. If the second CaseClauses is present, let names3 be the LexicallyDeclaredNames of the second CaseClauses.
  5. Else, let names3 be a new empty List.
  6. Return the list-concatenation of names1, names2, and names3.
CaseClauses : CaseClauses CaseClause
  1. Let names1 be the LexicallyDeclaredNames of CaseClauses.
  2. Let names2 be the LexicallyDeclaredNames of CaseClause.
  3. Return the list-concatenation of names1 and names2.
CaseClause : case Expression : StatementListopt
  1. If the StatementList is present, return the LexicallyDeclaredNames of StatementList.
  2. Return a new empty List.
DefaultClause : default : StatementListopt
  1. If the StatementList is present, return the LexicallyDeclaredNames of StatementList.
  2. Return a new empty List.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Return the LexicallyDeclaredNames of LabelledItem.
LabelledItem : Statement
  1. Return a new empty List.
LabelledItem : FunctionDeclaration
  1. Return the BoundNames of FunctionDeclaration.
FunctionStatementList : [empty]
  1. Return a new empty List.
FunctionStatementList : StatementList
  1. Return the TopLevelLexicallyDeclaredNames of StatementList.
ClassStaticBlockStatementList : [empty]
  1. Return a new empty List.
ClassStaticBlockStatementList : StatementList
  1. Return the TopLevelLexicallyDeclaredNames of StatementList.
ConciseBody : ExpressionBody
  1. Return a new empty List.
AsyncConciseBody : ExpressionBody
  1. Return a new empty List.
Script : [empty]
  1. Return a new empty List.
ScriptBody : StatementList
  1. Return the TopLevelLexicallyDeclaredNames of StatementList.
Note 1

At the top level of a Script, function declarations are treated like var declarations rather than like lexical declarations.

Note 2

The LexicallyDeclaredNames of a Module includes the names of all of its imported bindings.

ModuleItemList : ModuleItemList ModuleItem
  1. Let names1 be the LexicallyDeclaredNames of ModuleItemList.
  2. Let names2 be the LexicallyDeclaredNames of ModuleItem.
  3. Return the list-concatenation of names1 and names2.
ModuleItem : ImportDeclaration
  1. Return the BoundNames of ImportDeclaration.
ModuleItem : ExportDeclaration
  1. If ExportDeclaration is export VariableStatement, return a new empty List.
  2. Return the BoundNames of ExportDeclaration.
ModuleItem : StatementListItem
  1. Return the LexicallyDeclaredNames of StatementListItem.
Note 3

At the top level of a Module, function declarations are treated like lexical declarations rather than like var declarations.

8.2.5 Static Semantics: LexicallyScopedDeclarations

The syntax-directed operation LexicallyScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. Let declarations1 be the LexicallyScopedDeclarations of StatementList.
  2. Let declarations2 be the LexicallyScopedDeclarations of StatementListItem.
  3. Return the list-concatenation of declarations1 and declarations2.
StatementListItem : Statement
  1. If Statement is Statement : LabelledStatement , return the LexicallyScopedDeclarations of LabelledStatement.
  2. Return a new empty List.
StatementListItem : Declaration
  1. Return a List whose sole element is the DeclarationPart of Declaration.
CaseBlock : { }
  1. Return a new empty List.
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. If the first CaseClauses is present, let declarations1 be the LexicallyScopedDeclarations of the first CaseClauses.
  2. Else, let declarations1 be a new empty List.
  3. Let declarations2 be the LexicallyScopedDeclarations of DefaultClause.
  4. If the second CaseClauses is present, let declarations3 be the LexicallyScopedDeclarations of the second CaseClauses.
  5. Else, let declarations3 be a new empty List.
  6. Return the list-concatenation of declarations1, declarations2, and declarations3.
CaseClauses : CaseClauses CaseClause
  1. Let declarations1 be the LexicallyScopedDeclarations of CaseClauses.
  2. Let declarations2 be the LexicallyScopedDeclarations of CaseClause.
  3. Return the list-concatenation of declarations1 and declarations2.
CaseClause : case Expression : StatementListopt
  1. If the StatementList is present, return the LexicallyScopedDeclarations of StatementList.
  2. Return a new empty List.
DefaultClause : default : StatementListopt
  1. If the StatementList is present, return the LexicallyScopedDeclarations of StatementList.
  2. Return a new empty List.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Return the LexicallyScopedDeclarations of LabelledItem.
LabelledItem : Statement
  1. Return a new empty List.
LabelledItem : FunctionDeclaration
  1. Return « FunctionDeclaration ».
FunctionStatementList : [empty]
  1. Return a new empty List.
FunctionStatementList : StatementList
  1. Return the TopLevelLexicallyScopedDeclarations of StatementList.
ClassStaticBlockStatementList : [empty]
  1. Return a new empty List.
ClassStaticBlockStatementList : StatementList
  1. Return the TopLevelLexicallyScopedDeclarations of StatementList.
ConciseBody : ExpressionBody
  1. Return a new empty List.
AsyncConciseBody : ExpressionBody
  1. Return a new empty List.
Script : [empty]
  1. Return a new empty List.
ScriptBody : StatementList
  1. Return the TopLevelLexicallyScopedDeclarations of StatementList.
Module : [empty]
  1. Return a new empty List.
ModuleItemList : ModuleItemList ModuleItem
  1. Let declarations1 be the LexicallyScopedDeclarations of ModuleItemList.
  2. Let declarations2 be the LexicallyScopedDeclarations of ModuleItem.
  3. Return the list-concatenation of declarations1 and declarations2.
ModuleItem : ImportDeclaration
  1. Return a new empty List.
ExportDeclaration : export ExportFromClause FromClause ; export NamedExports ; export VariableStatement
  1. Return a new empty List.
ExportDeclaration : export Declaration
  1. Return a List whose sole element is the DeclarationPart of Declaration.
ExportDeclaration : export default HoistableDeclaration
  1. Return a List whose sole element is the DeclarationPart of HoistableDeclaration.
ExportDeclaration : export default ClassDeclaration
  1. Return a List whose sole element is ClassDeclaration.
ExportDeclaration : export default AssignmentExpression ;
  1. Return a List whose sole element is this ExportDeclaration.

8.2.6 Static Semantics: VarDeclaredNames

The syntax-directed operation VarDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

Statement : EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement
  1. Return a new empty List.
Block : { }
  1. Return a new empty List.
StatementList : StatementList StatementListItem
  1. Let names1 be the VarDeclaredNames of StatementList.
  2. Let names2 be the VarDeclaredNames of StatementListItem.
  3. Return the list-concatenation of names1 and names2.
StatementListItem : Declaration
  1. Return a new empty List.
VariableStatement : var VariableDeclarationList ;
  1. Return the BoundNames of VariableDeclarationList.
IfStatement : if ( Expression ) Statement else Statement
  1. Let names1 be the VarDeclaredNames of the first Statement.
  2. Let names2 be the VarDeclaredNames of the second Statement.
  3. Return the list-concatenation of names1 and names2.
IfStatement : if ( Expression ) Statement
  1. Return the VarDeclaredNames of Statement.
DoWhileStatement : do Statement while ( Expression ) ;
  1. Return the VarDeclaredNames of Statement.
WhileStatement : while ( Expression ) Statement
  1. Return the VarDeclaredNames of Statement.
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
  1. Return the VarDeclaredNames of Statement.
ForStatement : for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
  1. Let names1 be the BoundNames of VariableDeclarationList.
  2. Let names2 be the VarDeclaredNames of Statement.
  3. Return the list-concatenation of names1 and names2.
ForStatement : for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. Return the VarDeclaredNames of Statement.
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. Return the VarDeclaredNames of Statement.
ForInOfStatement : for ( var ForBinding in Expression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement
  1. Let names1 be the BoundNames of ForBinding.
  2. Let names2 be the VarDeclaredNames of Statement.
  3. Return the list-concatenation of names1 and names2.
Note

This section is extended by Annex B.3.5.

WithStatement : with ( Expression ) Statement
  1. Return the VarDeclaredNames of Statement.
SwitchStatement : switch ( Expression ) CaseBlock
  1. Return the VarDeclaredNames of CaseBlock.
CaseBlock : { }
  1. Return a new empty List.
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. If the first CaseClauses is present, let names1 be the VarDeclaredNames of the first CaseClauses.
  2. Else, let names1 be a new empty List.
  3. Let names2 be the VarDeclaredNames of DefaultClause.
  4. If the second CaseClauses is present, let names3 be the VarDeclaredNames of the second CaseClauses.
  5. Else, let names3 be a new empty List.
  6. Return the list-concatenation of names1, names2, and names3.
CaseClauses : CaseClauses CaseClause
  1. Let names1 be the VarDeclaredNames of CaseClauses.
  2. Let names2 be the VarDeclaredNames of CaseClause.
  3. Return the list-concatenation of names1 and names2.
CaseClause : case Expression : StatementListopt
  1. If the StatementList is present, return the VarDeclaredNames of StatementList.
  2. Return a new empty List.
DefaultClause : default : StatementListopt
  1. If the StatementList is present, return the VarDeclaredNames of StatementList.
  2. Return a new empty List.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Return the VarDeclaredNames of LabelledItem.
LabelledItem : FunctionDeclaration
  1. Return a new empty List.
TryStatement : try Block Catch
  1. Let names1 be the VarDeclaredNames of Block.
  2. Let names2 be the VarDeclaredNames of Catch.
  3. Return the list-concatenation of names1 and names2.
TryStatement : try Block Finally
  1. Let names1 be the VarDeclaredNames of Block.
  2. Let names2 be the VarDeclaredNames of Finally.
  3. Return the list-concatenation of names1 and names2.
TryStatement : try Block Catch Finally
  1. Let names1 be the VarDeclaredNames of Block.
  2. Let names2 be the VarDeclaredNames of Catch.
  3. Let names3 be the VarDeclaredNames of Finally.
  4. Return the list-concatenation of names1, names2, and names3.
Catch : catch ( CatchParameter ) Block
  1. Return the VarDeclaredNames of Block.
FunctionStatementList : [empty]
  1. Return a new empty List.
FunctionStatementList : StatementList
  1. Return the TopLevelVarDeclaredNames of StatementList.
ClassStaticBlockStatementList : [empty]
  1. Return a new empty List.
ClassStaticBlockStatementList : StatementList
  1. Return the TopLevelVarDeclaredNames of StatementList.
ConciseBody : ExpressionBody
  1. Return a new empty List.
AsyncConciseBody : ExpressionBody
  1. Return a new empty List.
Script : [empty]
  1. Return a new empty List.
ScriptBody : StatementList
  1. Return the TopLevelVarDeclaredNames of StatementList.
ModuleItemList : ModuleItemList ModuleItem
  1. Let names1 be the VarDeclaredNames of ModuleItemList.
  2. Let names2 be the VarDeclaredNames of ModuleItem.
  3. Return the list-concatenation of names1 and names2.
ModuleItem : ImportDeclaration
  1. Return a new empty List.
ModuleItem : ExportDeclaration
  1. If ExportDeclaration is export VariableStatement, return the BoundNames of ExportDeclaration.
  2. Return a new empty List.

8.2.7 Static Semantics: VarScopedDeclarations

The syntax-directed operation VarScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

Statement : EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement
  1. Return a new empty List.
Block : { }
  1. Return a new empty List.
StatementList : StatementList StatementListItem
  1. Let declarations1 be the VarScopedDeclarations of StatementList.
  2. Let declarations2 be the VarScopedDeclarations of StatementListItem.
  3. Return the list-concatenation of declarations1 and declarations2.
StatementListItem : Declaration
  1. Return a new empty List.
VariableDeclarationList : VariableDeclaration
  1. Return « VariableDeclaration ».
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. Let declarations1 be the VarScopedDeclarations of VariableDeclarationList.
  2. Return the list-concatenation of declarations1 and « VariableDeclaration ».
IfStatement : if ( Expression ) Statement else Statement
  1. Let declarations1 be the VarScopedDeclarations of the first Statement.
  2. Let declarations2 be the VarScopedDeclarations of the second Statement.
  3. Return the list-concatenation of declarations1 and declarations2.
IfStatement : if ( Expression ) Statement
  1. Return the VarScopedDeclarations of Statement.
DoWhileStatement : do Statement while ( Expression ) ;
  1. Return the VarScopedDeclarations of Statement.
WhileStatement : while ( Expression ) Statement
  1. Return the VarScopedDeclarations of Statement.
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
  1. Return the VarScopedDeclarations of Statement.
ForStatement : for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
  1. Let declarations1 be the VarScopedDeclarations of VariableDeclarationList.
  2. Let declarations2 be the VarScopedDeclarations of Statement.
  3. Return the list-concatenation of declarations1 and declarations2.
ForStatement : for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. Return the VarScopedDeclarations of Statement.
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. Return the VarScopedDeclarations of Statement.
ForInOfStatement : for ( var ForBinding in Expression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement
  1. Let declarations1 be « ForBinding ».
  2. Let declarations2 be the VarScopedDeclarations of Statement.
  3. Return the list-concatenation of declarations1 and declarations2.
Note

This section is extended by Annex B.3.5.

WithStatement : with ( Expression ) Statement
  1. Return the VarScopedDeclarations of Statement.
SwitchStatement : switch ( Expression ) CaseBlock
  1. Return the VarScopedDeclarations of CaseBlock.
CaseBlock : { }
  1. Return a new empty List.
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. If the first CaseClauses is present, let declarations1 be the VarScopedDeclarations of the first CaseClauses.
  2. Else, let declarations1 be a new empty List.
  3. Let declarations2 be the VarScopedDeclarations of DefaultClause.
  4. If the second CaseClauses is present, let declarations3 be the VarScopedDeclarations of the second CaseClauses.
  5. Else, let declarations3 be a new empty List.
  6. Return the list-concatenation of declarations1, declarations2, and declarations3.
CaseClauses : CaseClauses CaseClause
  1. Let declarations1 be the VarScopedDeclarations of CaseClauses.
  2. Let declarations2 be the VarScopedDeclarations of CaseClause.
  3. Return the list-concatenation of declarations1 and declarations2.
CaseClause : case Expression : StatementListopt
  1. If the StatementList is present, return the VarScopedDeclarations of StatementList.
  2. Return a new empty List.
DefaultClause : default : StatementListopt
  1. If the StatementList is present, return the VarScopedDeclarations of StatementList.
  2. Return a new empty List.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Return the VarScopedDeclarations of LabelledItem.
LabelledItem : FunctionDeclaration
  1. Return a new empty List.
TryStatement : try Block Catch
  1. Let declarations1 be the VarScopedDeclarations of Block.
  2. Let declarations2 be the VarScopedDeclarations of Catch.
  3. Return the list-concatenation of declarations1 and declarations2.
TryStatement : try Block Finally
  1. Let declarations1 be the VarScopedDeclarations of Block.
  2. Let declarations2 be the VarScopedDeclarations of Finally.
  3. Return the list-concatenation of declarations1 and declarations2.
TryStatement : try Block Catch Finally
  1. Let declarations1 be the VarScopedDeclarations of Block.
  2. Let declarations2 be the VarScopedDeclarations of Catch.
  3. Let declarations3 be the VarScopedDeclarations of Finally.
  4. Return the list-concatenation of declarations1, declarations2, and declarations3.
Catch : catch ( CatchParameter ) Block
  1. Return the VarScopedDeclarations of Block.
FunctionStatementList : [empty]
  1. Return a new empty List.
FunctionStatementList : StatementList
  1. Return the TopLevelVarScopedDeclarations of StatementList.
ClassStaticBlockStatementList : [empty]
  1. Return a new empty List.
ClassStaticBlockStatementList : StatementList
  1. Return the TopLevelVarScopedDeclarations of StatementList.
ConciseBody : ExpressionBody
  1. Return a new empty List.
AsyncConciseBody : ExpressionBody
  1. Return a new empty List.
Script : [empty]
  1. Return a new empty List.
ScriptBody : StatementList
  1. Return the TopLevelVarScopedDeclarations of StatementList.
Module : [empty]
  1. Return a new empty List.
ModuleItemList : ModuleItemList ModuleItem
  1. Let declarations1 be the VarScopedDeclarations of ModuleItemList.
  2. Let declarations2 be the VarScopedDeclarations of ModuleItem.
  3. Return the list-concatenation of declarations1 and declarations2.
ModuleItem : ImportDeclaration
  1. Return a new empty List.
ModuleItem : ExportDeclaration
  1. If ExportDeclaration is export VariableStatement, return the VarScopedDeclarations of VariableStatement.
  2. Return a new empty List.

8.2.8 Static Semantics: TopLevelLexicallyDeclaredNames

The syntax-directed operation TopLevelLexicallyDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. Let names1 be the TopLevelLexicallyDeclaredNames of StatementList.
  2. Let names2 be the TopLevelLexicallyDeclaredNames of StatementListItem.
  3. Return the list-concatenation of names1 and names2.
StatementListItem : Statement
  1. Return a new empty List.
StatementListItem : Declaration
  1. If Declaration is Declaration : HoistableDeclaration , then
    1. Return a new empty List.
  2. Return the BoundNames of Declaration.
Note

At the top level of a function, or script, function declarations are treated like var declarations rather than like lexical declarations.

8.2.9 Static Semantics: TopLevelLexicallyScopedDeclarations

The syntax-directed operation TopLevelLexicallyScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. Let declarations1 be the TopLevelLexicallyScopedDeclarations of StatementList.
  2. Let declarations2 be the TopLevelLexicallyScopedDeclarations of StatementListItem.
  3. Return the list-concatenation of declarations1 and declarations2.
StatementListItem : Statement
  1. Return a new empty List.
StatementListItem : Declaration
  1. If Declaration is Declaration : HoistableDeclaration , then
    1. Return a new empty List.
  2. Return « Declaration ».

8.2.10 Static Semantics: TopLevelVarDeclaredNames

The syntax-directed operation TopLevelVarDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. Let names1 be the TopLevelVarDeclaredNames of StatementList.
  2. Let names2 be the TopLevelVarDeclaredNames of StatementListItem.
  3. Return the list-concatenation of names1 and names2.
StatementListItem : Declaration
  1. If Declaration is Declaration : HoistableDeclaration , then
    1. Return the BoundNames of HoistableDeclaration.
  2. Return a new empty List.
StatementListItem : Statement
  1. If Statement is Statement : LabelledStatement , return the TopLevelVarDeclaredNames of Statement.
  2. Return the VarDeclaredNames of Statement.
Note

At the top level of a function or script, inner function declarations are treated like var declarations.

LabelledStatement : LabelIdentifier : LabelledItem
  1. Return the TopLevelVarDeclaredNames of LabelledItem.
LabelledItem : Statement
  1. If Statement is Statement : LabelledStatement , return the TopLevelVarDeclaredNames of Statement.
  2. Return the VarDeclaredNames of Statement.
LabelledItem : FunctionDeclaration
  1. Return the BoundNames of FunctionDeclaration.

8.2.11 Static Semantics: TopLevelVarScopedDeclarations

The syntax-directed operation TopLevelVarScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. Let declarations1 be the TopLevelVarScopedDeclarations of StatementList.
  2. Let declarations2 be the TopLevelVarScopedDeclarations of StatementListItem.
  3. Return the list-concatenation of declarations1 and declarations2.
StatementListItem : Statement
  1. If Statement is Statement : LabelledStatement , return the TopLevelVarScopedDeclarations of Statement.
  2. Return the VarScopedDeclarations of Statement.
StatementListItem : Declaration
  1. If Declaration is Declaration : HoistableDeclaration , then
    1. Let declaration be the DeclarationPart of HoistableDeclaration.
    2. Return « declaration ».
  2. Return a new empty List.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Return the TopLevelVarScopedDeclarations of LabelledItem.
LabelledItem : Statement
  1. If Statement is Statement : LabelledStatement , return the TopLevelVarScopedDeclarations of Statement.
  2. Return the VarScopedDeclarations of Statement.
LabelledItem : FunctionDeclaration
  1. Return « FunctionDeclaration ».

8.3 Labels

8.3.1 Static Semantics: ContainsDuplicateLabels

The syntax-directed operation ContainsDuplicateLabels takes argument labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. Return false.
StatementList : StatementList StatementListItem
  1. Let hasDuplicates be ContainsDuplicateLabels of StatementList with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Return ContainsDuplicateLabels of StatementListItem with argument labelSet.
IfStatement : if ( Expression ) Statement else Statement
  1. Let hasDuplicate be ContainsDuplicateLabels of the first Statement with argument labelSet.
  2. If hasDuplicate is true, return true.
  3. Return ContainsDuplicateLabels of the second Statement with argument labelSet.
IfStatement : if ( Expression ) Statement
  1. Return ContainsDuplicateLabels of Statement with argument labelSet.
DoWhileStatement : do Statement while ( Expression ) ;
  1. Return ContainsDuplicateLabels of Statement with argument labelSet.
WhileStatement : while ( Expression ) Statement
  1. Return ContainsDuplicateLabels of Statement with argument labelSet.
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. Return ContainsDuplicateLabels of Statement with argument labelSet.
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement 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.
Note

This section is extended by Annex B.3.5.

WithStatement : with ( Expression ) Statement
  1. Return ContainsDuplicateLabels of Statement with argument labelSet.
SwitchStatement : switch ( Expression ) CaseBlock
  1. Return ContainsDuplicateLabels of CaseBlock with argument labelSet.
CaseBlock : { }
  1. Return false.
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. If the first CaseClauses is present, then
    1. If ContainsDuplicateLabels of the first CaseClauses with argument labelSet is true, return true.
  2. If ContainsDuplicateLabels of DefaultClause with argument labelSet is true, return true.
  3. If the second CaseClauses is not present, return false.
  4. Return ContainsDuplicateLabels of the second CaseClauses with argument labelSet.
CaseClauses : CaseClauses CaseClause
  1. Let hasDuplicates be ContainsDuplicateLabels of CaseClauses with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Return ContainsDuplicateLabels of CaseClause with argument labelSet.
CaseClause : case Expression : StatementListopt
  1. If the StatementList is present, return ContainsDuplicateLabels of StatementList with argument labelSet.
  2. Return false.
DefaultClause : default : StatementListopt
  1. If the StatementList is present, return ContainsDuplicateLabels of StatementList with argument labelSet.
  2. Return false.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Let label be the StringValue of LabelIdentifier.
  2. If labelSet contains label, return true.
  3. Let newLabelSet be the list-concatenation of labelSet and « label ».
  4. Return ContainsDuplicateLabels of LabelledItem with argument newLabelSet.
LabelledItem : FunctionDeclaration
  1. Return false.
TryStatement : try Block Catch
  1. Let hasDuplicates be ContainsDuplicateLabels of Block with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Return ContainsDuplicateLabels of Catch with argument labelSet.
TryStatement : try Block Finally
  1. Let hasDuplicates be ContainsDuplicateLabels of Block with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Return ContainsDuplicateLabels of Finally with argument labelSet.
TryStatement : try Block Catch Finally
  1. If ContainsDuplicateLabels of Block with argument labelSet is true, return true.
  2. If ContainsDuplicateLabels of Catch with argument labelSet is true, return true.
  3. Return ContainsDuplicateLabels of Finally with argument labelSet.
Catch : catch ( CatchParameter ) Block
  1. Return ContainsDuplicateLabels of Block with argument labelSet.
FunctionStatementList : [empty]
  1. Return false.
ClassStaticBlockStatementList : [empty]
  1. Return false.
ModuleItemList : ModuleItemList ModuleItem
  1. Let hasDuplicates be ContainsDuplicateLabels of ModuleItemList with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Return ContainsDuplicateLabels of ModuleItem with argument labelSet.
ModuleItem : ImportDeclaration ExportDeclaration
  1. Return false.

8.3.2 Static Semantics: ContainsUndefinedBreakTarget

The syntax-directed operation ContainsUndefinedBreakTarget takes argument labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement ContinueStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. Return false.
StatementList : StatementList StatementListItem
  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of StatementList with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of StatementListItem with argument labelSet.
IfStatement : if ( Expression ) Statement else Statement
  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of the first Statement with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of the second Statement with argument labelSet.
IfStatement : if ( Expression ) Statement
  1. Return ContainsUndefinedBreakTarget of Statement with argument labelSet.
DoWhileStatement : do Statement while ( Expression ) ;
  1. Return ContainsUndefinedBreakTarget of Statement with argument labelSet.
WhileStatement : while ( Expression ) Statement
  1. Return ContainsUndefinedBreakTarget of Statement with argument labelSet.
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. Return ContainsUndefinedBreakTarget of Statement with argument labelSet.
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement 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.
Note

This section is extended by Annex B.3.5.

BreakStatement : break ;
  1. Return false.
BreakStatement : break LabelIdentifier ;
  1. If labelSet does not contain the StringValue of LabelIdentifier, return true.
  2. Return false.
WithStatement : with ( Expression ) Statement
  1. Return ContainsUndefinedBreakTarget of Statement with argument labelSet.
SwitchStatement : switch ( Expression ) CaseBlock
  1. Return ContainsUndefinedBreakTarget of CaseBlock with argument labelSet.
CaseBlock : { }
  1. Return false.
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. If the first CaseClauses is present, then
    1. If ContainsUndefinedBreakTarget of the first CaseClauses with argument labelSet is true, return true.
  2. If ContainsUndefinedBreakTarget of DefaultClause with argument labelSet is true, return true.
  3. If the second CaseClauses is not present, return false.
  4. Return ContainsUndefinedBreakTarget of the second CaseClauses with argument labelSet.
CaseClauses : CaseClauses CaseClause
  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of CaseClauses with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of CaseClause with argument labelSet.
CaseClause : case Expression : StatementListopt
  1. If the StatementList is present, return ContainsUndefinedBreakTarget of StatementList with argument labelSet.
  2. Return false.
DefaultClause : default : StatementListopt
  1. If the StatementList is present, return ContainsUndefinedBreakTarget of StatementList with argument labelSet.
  2. Return false.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Let label be the StringValue of LabelIdentifier.
  2. Let newLabelSet be the list-concatenation of labelSet and « label ».
  3. Return ContainsUndefinedBreakTarget of LabelledItem with argument newLabelSet.
LabelledItem : FunctionDeclaration
  1. Return false.
TryStatement : try Block Catch
  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of Block with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of Catch with argument labelSet.
TryStatement : try Block Finally
  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of Block with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of Finally with argument labelSet.
TryStatement : try Block Catch Finally
  1. If ContainsUndefinedBreakTarget of Block with argument labelSet is true, return true.
  2. If ContainsUndefinedBreakTarget of Catch with argument labelSet is true, return true.
  3. Return ContainsUndefinedBreakTarget of Finally with argument labelSet.
Catch : catch ( CatchParameter ) Block
  1. Return ContainsUndefinedBreakTarget of Block with argument labelSet.
FunctionStatementList : [empty]
  1. Return false.
ClassStaticBlockStatementList : [empty]
  1. Return false.
ModuleItemList : ModuleItemList ModuleItem
  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of ModuleItemList with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of ModuleItem with argument labelSet.
ModuleItem : ImportDeclaration ExportDeclaration
  1. Return false.

8.3.3 Static Semantics: ContainsUndefinedContinueTarget

The syntax-directed operation ContainsUndefinedContinueTarget takes arguments iterationSet (a List of Strings) and labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. Return false.
Statement : BlockStatement
  1. Return ContainsUndefinedContinueTarget of BlockStatement with arguments iterationSet and « ».
BreakableStatement : IterationStatement
  1. Let newIterationSet be the list-concatenation of iterationSet and labelSet.
  2. Return ContainsUndefinedContinueTarget of IterationStatement with arguments newIterationSet and « ».
StatementList : StatementList StatementListItem
  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of StatementList with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of StatementListItem with arguments iterationSet and « ».
IfStatement : if ( Expression ) Statement else Statement
  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of the first Statement with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of the second Statement with arguments iterationSet and « ».
IfStatement : if ( Expression ) Statement
  1. Return ContainsUndefinedContinueTarget of Statement with arguments iterationSet and « ».
DoWhileStatement : do Statement while ( Expression ) ;
  1. Return ContainsUndefinedContinueTarget of Statement with arguments iterationSet and « ».
WhileStatement : while ( Expression ) Statement
  1. Return ContainsUndefinedContinueTarget of Statement with arguments iterationSet and « ».
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. Return ContainsUndefinedContinueTarget of Statement with arguments iterationSet and « ».
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement 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 « ».
Note

This section is extended by Annex B.3.5.

ContinueStatement : continue ;
  1. Return false.
ContinueStatement : continue LabelIdentifier ;
  1. If iterationSet does not contain the StringValue of LabelIdentifier, return true.
  2. Return false.
WithStatement : with ( Expression ) Statement
  1. Return ContainsUndefinedContinueTarget of Statement with arguments iterationSet and « ».
SwitchStatement : switch ( Expression ) CaseBlock
  1. Return ContainsUndefinedContinueTarget of CaseBlock with arguments iterationSet and « ».
CaseBlock : { }
  1. Return false.
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. If the first CaseClauses is present, then
    1. If ContainsUndefinedContinueTarget of the first CaseClauses with arguments iterationSet and « » is true, return true.
  2. If ContainsUndefinedContinueTarget of DefaultClause with arguments iterationSet and « » is true, return true.
  3. If the second CaseClauses is not present, return false.
  4. Return ContainsUndefinedContinueTarget of the second CaseClauses with arguments iterationSet and « ».
CaseClauses : CaseClauses CaseClause
  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of CaseClauses with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of CaseClause with arguments iterationSet and « ».
CaseClause : case Expression : StatementListopt
  1. If the StatementList is present, return ContainsUndefinedContinueTarget of StatementList with arguments iterationSet and « ».
  2. Return false.
DefaultClause : default : StatementListopt
  1. If the StatementList is present, return ContainsUndefinedContinueTarget of StatementList with arguments iterationSet and « ».
  2. Return false.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Let label be the StringValue of LabelIdentifier.
  2. Let newLabelSet be the list-concatenation of labelSet and « label ».
  3. Return ContainsUndefinedContinueTarget of LabelledItem with arguments iterationSet and newLabelSet.
LabelledItem : FunctionDeclaration
  1. Return false.
TryStatement : try Block Catch
  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of Block with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of Catch with arguments iterationSet and « ».
TryStatement : try Block Finally
  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of Block with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of Finally with arguments iterationSet and « ».
TryStatement : try Block Catch Finally
  1. If ContainsUndefinedContinueTarget of Block with arguments iterationSet and « » is true, return true.
  2. If ContainsUndefinedContinueTarget of Catch with arguments iterationSet and « » is true, return true.
  3. Return ContainsUndefinedContinueTarget of Finally with arguments iterationSet and « ».
Catch : catch ( CatchParameter ) Block
  1. Return ContainsUndefinedContinueTarget of Block with arguments iterationSet and « ».
FunctionStatementList : [empty]
  1. Return false.
ClassStaticBlockStatementList : [empty]
  1. Return false.
ModuleItemList : ModuleItemList ModuleItem
  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of ModuleItemList with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of ModuleItem with arguments iterationSet and « ».
ModuleItem : ImportDeclaration ExportDeclaration
  1. Return false.

8.4 Function Name Inference

8.4.1 Static Semantics: HasName

The syntax-directed operation HasName takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. Let expr be the ParenthesizedExpression that is covered by CoverParenthesizedExpressionAndArrowParameterList.
  2. If IsFunctionDefinition of expr is false, return false.
  3. Return HasName of expr.
FunctionExpression : function ( FormalParameters ) { FunctionBody } GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } AsyncGeneratorExpression : async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } ArrowFunction : ArrowParameters => ConciseBody AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody ClassExpression : class ClassTail
  1. Return false.
FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } ClassExpression : class BindingIdentifier ClassTail
  1. Return true.

8.4.2 Static Semantics: IsFunctionDefinition

The syntax-directed operation IsFunctionDefinition takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. Let expr be the ParenthesizedExpression that is covered by CoverParenthesizedExpressionAndArrowParameterList.
  2. Return IsFunctionDefinition of expr.
PrimaryExpression : this IdentifierReference Literal ArrayLiteral ObjectLiteral RegularExpressionLiteral TemplateLiteral MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName MemberExpression TemplateLiteral SuperProperty MetaProperty new MemberExpression Arguments MemberExpression . PrivateIdentifier NewExpression : new NewExpression LeftHandSideExpression : CallExpression OptionalExpression UpdateExpression : LeftHandSideExpression ++ LeftHandSideExpression -- ++ UnaryExpression -- UnaryExpression UnaryExpression : delete UnaryExpression void UnaryExpression typeof UnaryExpression + UnaryExpression - UnaryExpression ~ UnaryExpression ! UnaryExpression AwaitExpression ExponentiationExpression : UpdateExpression ** ExponentiationExpression MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression AdditiveExpression : AdditiveExpression + MultiplicativeExpression AdditiveExpression - MultiplicativeExpression ShiftExpression : ShiftExpression << AdditiveExpression ShiftExpression >> AdditiveExpression ShiftExpression >>> AdditiveExpression RelationalExpression : RelationalExpression < ShiftExpression RelationalExpression > ShiftExpression RelationalExpression <= ShiftExpression RelationalExpression >= ShiftExpression RelationalExpression instanceof ShiftExpression RelationalExpression in ShiftExpression PrivateIdentifier in ShiftExpression EqualityExpression : EqualityExpression == RelationalExpression EqualityExpression != RelationalExpression EqualityExpression === RelationalExpression EqualityExpression !== RelationalExpression BitwiseANDExpression : BitwiseANDExpression & EqualityExpression BitwiseXORExpression : BitwiseXORExpression ^ BitwiseANDExpression BitwiseORExpression : BitwiseORExpression | BitwiseXORExpression LogicalANDExpression : LogicalANDExpression && BitwiseORExpression LogicalORExpression : LogicalORExpression || LogicalANDExpression CoalesceExpression : CoalesceExpressionHead ?? BitwiseORExpression ConditionalExpression : ShortCircuitExpression ? AssignmentExpression : AssignmentExpression AssignmentExpression : YieldExpression LeftHandSideExpression = AssignmentExpression LeftHandSideExpression AssignmentOperator AssignmentExpression LeftHandSideExpression &&= AssignmentExpression LeftHandSideExpression ||= AssignmentExpression LeftHandSideExpression ??= AssignmentExpression Expression : Expression , AssignmentExpression
  1. Return false.
AssignmentExpression : ArrowFunction AsyncArrowFunction FunctionExpression : function BindingIdentifieropt ( FormalParameters ) { FunctionBody } GeneratorExpression : function * BindingIdentifieropt ( FormalParameters ) { GeneratorBody } AsyncGeneratorExpression : async function * BindingIdentifieropt ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionExpression : async function BindingIdentifieropt ( FormalParameters ) { AsyncFunctionBody } ClassExpression : class BindingIdentifieropt ClassTail
  1. Return true.

8.4.3 Static Semantics: IsAnonymousFunctionDefinition ( expr )

The abstract operation IsAnonymousFunctionDefinition takes argument expr (an AssignmentExpression Parse Node, an Initializer Parse Node, or an Expression Parse Node) and returns a Boolean. It determines if its argument is a function definition that does not bind a name. It performs the following steps when called:

  1. If IsFunctionDefinition of expr is false, return false.
  2. Let hasName be HasName of expr.
  3. If hasName is true, return false.
  4. Return true.

8.4.4 Static Semantics: IsIdentifierRef

The syntax-directed operation IsIdentifierRef takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

PrimaryExpression : IdentifierReference
  1. Return true.
PrimaryExpression : this Literal ArrayLiteral ObjectLiteral FunctionExpression ClassExpression GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral CoverParenthesizedExpressionAndArrowParameterList MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName MemberExpression TemplateLiteral SuperProperty MetaProperty new MemberExpression Arguments MemberExpression . PrivateIdentifier NewExpression : new NewExpression LeftHandSideExpression : CallExpression OptionalExpression
  1. Return false.

8.4.5 Runtime Semantics: NamedEvaluation

The syntax-directed operation NamedEvaluation takes argument name (a property key or a Private Name) and returns either a normal completion containing a function object or an abrupt completion. It is defined piecewise over the following productions:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. Let expr be the ParenthesizedExpression that is covered by CoverParenthesizedExpressionAndArrowParameterList.
  2. Return ? NamedEvaluation of expr with argument name.
ParenthesizedExpression : ( Expression )
  1. Assert: IsAnonymousFunctionDefinition(Expression) is true.
  2. Return ? NamedEvaluation of Expression with argument name.
FunctionExpression : function ( FormalParameters ) { FunctionBody }
  1. Return InstantiateOrdinaryFunctionExpression of FunctionExpression with argument name.
GeneratorExpression : function * ( FormalParameters ) { GeneratorBody }
  1. Return InstantiateGeneratorFunctionExpression of GeneratorExpression with argument name.
AsyncGeneratorExpression : async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. Return InstantiateAsyncGeneratorFunctionExpression of AsyncGeneratorExpression with argument name.
AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody }
  1. Return InstantiateAsyncFunctionExpression of AsyncFunctionExpression with argument name.
ArrowFunction : ArrowParameters => ConciseBody
  1. Return InstantiateArrowFunctionExpression of ArrowFunction with argument name.
AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
  1. Return InstantiateAsyncArrowFunctionExpression of AsyncArrowFunction with argument name.
ClassExpression : class ClassTail
  1. Let value be ? ClassDefinitionEvaluation of ClassTail with arguments undefined and name.
  2. Set value.[[SourceText]] to the source text matched by ClassExpression.
  3. Return value.

8.5 Contains

8.5.1 Static Semantics: Contains

The syntax-directed operation Contains takes argument symbol (a grammar symbol) and returns a Boolean.

Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of Contains:

  1. For each child node child of this Parse Node, do
    1. If child is an instance of symbol, return true.
    2. If child is an instance of a nonterminal, then
      1. Let contained be the result of child Contains symbol.
      2. If contained is true, return true.
  2. Return false.
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody } FunctionExpression : function BindingIdentifieropt ( FormalParameters ) { FunctionBody } GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody } GeneratorExpression : function * BindingIdentifieropt ( FormalParameters ) { GeneratorBody } AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncGeneratorExpression : async function * BindingIdentifieropt ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody } AsyncFunctionExpression : async function BindingIdentifieropt ( FormalParameters ) { AsyncFunctionBody }
  1. Return false.
Note 1

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

ClassTail : ClassHeritageopt { ClassBody }
  1. If symbol is ClassBody, return true.
  2. If symbol is ClassHeritage, then
    1. If ClassHeritage is present, return true; otherwise return false.
  3. If ClassHeritage is present, then
    1. If ClassHeritage Contains symbol is true, return true.
  4. Return the result of ComputedPropertyContains of ClassBody with argument symbol.
Note 2

Static semantic rules that depend upon substructure generally do not look into class bodies except for PropertyNames.

ClassStaticBlock : static { ClassStaticBlockBody }
  1. Return false.
Note 3

Static semantic rules that depend upon substructure generally do not look into static initialization blocks.

ArrowFunction : ArrowParameters => ConciseBody
  1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super, or this, return false.
  2. If ArrowParameters Contains symbol is true, return true.
  3. Return ConciseBody Contains symbol.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. Let formals be the ArrowFormalParameters that is covered by CoverParenthesizedExpressionAndArrowParameterList.
  2. Return formals Contains symbol.
AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody
  1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super, or this, return false.
  2. Return AsyncConciseBody Contains symbol.
AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
  1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super, or this, return false.
  2. Let head be the AsyncArrowHead that is covered by CoverCallExpressionAndAsyncArrowHead.
  3. If head Contains symbol is true, return true.
  4. Return AsyncConciseBody Contains symbol.
Note 4

Contains is used to detect new.target, this, and super usage within an ArrowFunction or AsyncArrowFunction.

PropertyDefinition : MethodDefinition
  1. If symbol is MethodDefinition, return true.
  2. Return the result of ComputedPropertyContains of MethodDefinition with argument symbol.
LiteralPropertyName : IdentifierName
  1. Return false.
MemberExpression : MemberExpression . IdentifierName
  1. If MemberExpression Contains symbol is true, return true.
  2. Return false.
SuperProperty : super . IdentifierName
  1. If symbol is the ReservedWord super, return true.
  2. Return false.
CallExpression : CallExpression . IdentifierName
  1. If CallExpression Contains symbol is true, return true.
  2. Return false.
OptionalChain : ?. IdentifierName
  1. Return false.
OptionalChain : OptionalChain . IdentifierName
  1. If OptionalChain Contains symbol is true, return true.
  2. Return false.

8.5.2 Static Semantics: ComputedPropertyContains

The syntax-directed operation ComputedPropertyContains takes argument symbol (a grammar symbol) and returns a Boolean. It is defined piecewise over the following productions:

ClassElementName : PrivateIdentifier PropertyName : LiteralPropertyName
  1. Return false.
PropertyName : ComputedPropertyName
  1. Return the result of ComputedPropertyName Contains symbol.
MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } get ClassElementName ( ) { FunctionBody } set ClassElementName ( PropertySetParameterList ) { FunctionBody }
  1. Return the result of ComputedPropertyContains of ClassElementName with argument symbol.
GeneratorMethod : * ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
  1. Return the result of ComputedPropertyContains of ClassElementName with argument symbol.
AsyncGeneratorMethod : async * ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody }
  1. Return the result of ComputedPropertyContains of ClassElementName with argument symbol.
ClassElementList : ClassElementList ClassElement
  1. Let inList be ComputedPropertyContains of ClassElementList with argument symbol.
  2. If inList is true, return true.
  3. Return the result of ComputedPropertyContains of ClassElement with argument symbol.
ClassElement : ClassStaticBlock
  1. Return false.
ClassElement : ;
  1. Return false.
AsyncMethod : async ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody }
  1. Return the result of ComputedPropertyContains of ClassElementName with argument symbol.
FieldDefinition : ClassElementName Initializeropt
  1. Return the result of ComputedPropertyContains of ClassElementName with argument symbol.

8.6 Miscellaneous

These operations are used in multiple places throughout the specification.

8.6.1 Runtime Semantics: InstantiateFunctionObject

The syntax-directed operation InstantiateFunctionObject takes arguments env (an Environment Record) and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. It is defined piecewise over the following productions:

FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody }
  1. Return InstantiateOrdinaryFunctionObject of FunctionDeclaration with arguments env and privateEnv.
GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody }
  1. Return InstantiateGeneratorFunctionObject of GeneratorDeclaration with arguments env and privateEnv.
AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. Return InstantiateAsyncGeneratorFunctionObject of AsyncGeneratorDeclaration with arguments env and privateEnv.
AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody }
  1. Return InstantiateAsyncFunctionObject of AsyncFunctionDeclaration with arguments env and privateEnv.

8.6.2 Runtime Semantics: BindingInitialization

The syntax-directed operation BindingInitialization takes arguments value (an ECMAScript language value) and environment (an Environment Record or undefined) and returns either a normal completion containing unused or an abrupt completion.

Note

undefined is passed for environment to indicate that a PutValue operation should be used to assign the initialization value. This is the case for var statements and formal parameter lists of some non-strict functions (See 10.2.11). In those cases a lexical binding is hoisted and preinitialized prior to evaluation of its initializer.

It is defined piecewise over the following productions:

BindingIdentifier : Identifier
  1. Let name be the StringValue of Identifier.
  2. Return ? InitializeBoundName(name, value, environment).
BindingIdentifier : yield
  1. Return ? InitializeBoundName("yield", value, environment).
BindingIdentifier : await
  1. Return ? InitializeBoundName("await", value, environment).
BindingPattern : ObjectBindingPattern
  1. Perform ? RequireObjectCoercible(value).
  2. Return ? BindingInitialization of ObjectBindingPattern with arguments value and environment.
BindingPattern : ArrayBindingPattern
  1. Let iteratorRecord be ? GetIterator(value, sync).
  2. Let result be Completion(IteratorBindingInitialization of ArrayBindingPattern with arguments iteratorRecord and environment).
  3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result).
  4. Return ? result.
ObjectBindingPattern : { }
  1. Return unused.
ObjectBindingPattern : { BindingPropertyList } { BindingPropertyList , }
  1. Perform ? PropertyBindingInitialization of BindingPropertyList with arguments value and environment.
  2. Return unused.
ObjectBindingPattern : { BindingRestProperty }
  1. Let excludedNames be a new empty List.
  2. Return ? RestBindingInitialization of BindingRestProperty with arguments value, environment, and excludedNames.
ObjectBindingPattern : { BindingPropertyList , BindingRestProperty }
  1. Let excludedNames be ? PropertyBindingInitialization of BindingPropertyList with arguments value and environment.
  2. Return ? RestBindingInitialization of BindingRestProperty with arguments value, environment, and excludedNames.

8.6.2.1 InitializeBoundName ( name, value, environment )

The abstract operation InitializeBoundName takes arguments name (a String), value (an ECMAScript language value), and environment (an Environment Record or undefined) and returns either a normal completion containing unused or an abrupt completion. It performs the following steps when called:

  1. If environment is not undefined, then
    1. Perform ! environment.InitializeBinding(name, value).
    2. Return unused.
  2. Else,
    1. Let lhs be ? ResolveBinding(name).
    2. Return ? PutValue(lhs, value).

8.6.3 Runtime Semantics: IteratorBindingInitialization

The syntax-directed operation IteratorBindingInitialization takes arguments iteratorRecord (an Iterator Record) and environment (an Environment Record or undefined) and returns either a normal completion containing unused or an abrupt completion.

Note

When undefined is passed for environment it indicates that a PutValue operation should be used to assign the initialization value. This is the case for formal parameter lists of non-strict functions. In that case the formal parameter bindings are preinitialized in order to deal with the possibility of multiple parameters with the same name.

It is defined piecewise over the following productions:

ArrayBindingPattern : [ ]
  1. Return unused.
ArrayBindingPattern : [ Elision ]
  1. Return ? IteratorDestructuringAssignmentEvaluation of Elision with argument iteratorRecord.
ArrayBindingPattern : [ Elisionopt BindingRestElement ]
  1. If Elision is present, then
    1. Perform ? IteratorDestructuringAssignmentEvaluation of Elision with argument iteratorRecord.
  2. Return ? IteratorBindingInitialization of BindingRestElement with arguments iteratorRecord and environment.
ArrayBindingPattern : [ BindingElementList , Elision ]
  1. Perform ? IteratorBindingInitialization of BindingElementList with arguments iteratorRecord and environment.
  2. Return ? IteratorDestructuringAssignmentEvaluation of Elision with argument iteratorRecord.
ArrayBindingPattern : [ BindingElementList , Elisionopt BindingRestElement ]
  1. Perform ? IteratorBindingInitialization of BindingElementList with arguments iteratorRecord and environment.
  2. If Elision is present, then
    1. Perform ? IteratorDestructuringAssignmentEvaluation of Elision with argument iteratorRecord.
  3. Return ? IteratorBindingInitialization of BindingRestElement with arguments iteratorRecord and environment.
BindingElementList : BindingElementList , BindingElisionElement
  1. Perform ? IteratorBindingInitialization of BindingElementList with arguments iteratorRecord and environment.
  2. Return ? IteratorBindingInitialization of BindingElisionElement with arguments iteratorRecord and environment.
BindingElisionElement : Elision BindingElement
  1. Perform ? IteratorDestructuringAssignmentEvaluation of Elision with argument iteratorRecord.
  2. Return ? IteratorBindingInitialization of BindingElement with arguments iteratorRecord and environment.
SingleNameBinding : BindingIdentifier Initializeropt
  1. Let bindingId be the StringValue of BindingIdentifier.
  2. Let lhs be ? ResolveBinding(bindingId, environment).
  3. Let v be undefined.
  4. If iteratorRecord.[[Done]] is false, then
    1. Let next be ? IteratorStepValue(iteratorRecord).
    2. If next is not done, then
      1. Set v to next.
  5. If Initializer is present and v is undefined, then
    1. If IsAnonymousFunctionDefinition(Initializer) is true, then
      1. Set v to ? NamedEvaluation of Initializer with argument bindingId.
    2. Else,
      1. Let defaultValue be ? Evaluation of Initializer.
      2. Set v to ? GetValue(defaultValue).
  6. If environment is undefined, return ? PutValue(lhs, v).
  7. Return ? InitializeReferencedBinding(lhs, v).
BindingElement : BindingPattern Initializeropt
  1. Let v be undefined.
  2. If iteratorRecord.[[Done]] is false, then
    1. Let next be ? IteratorStepValue(iteratorRecord).
    2. If next is not done, then
      1. Set v to next.
  3. If Initializer is present and v is undefined, then
    1. Let defaultValue be ? Evaluation of Initializer.
    2. Set v to ? GetValue(defaultValue).
  4. Return ? BindingInitialization of BindingPattern with arguments v and environment.
BindingRestElement : ... BindingIdentifier
  1. Let lhs be ? ResolveBinding(StringValue of BindingIdentifier, environment).
  2. Let A be ! ArrayCreate(0).
  3. Let n be 0.
  4. Repeat,
    1. Let next be done.
    2. If iteratorRecord.[[Done]] is false, then
      1. Set next to ? IteratorStepValue(iteratorRecord).
    3. If next is done, then
      1. If environment is undefined, return ? PutValue(lhs, A).
      2. Return ? InitializeReferencedBinding(lhs, A).
    4. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(n)), next).
    5. Set n to n + 1.
BindingRestElement : ... BindingPattern
  1. Let A be ! ArrayCreate(0).
  2. Let n be 0.
  3. Repeat,
    1. Let next be done.
    2. If iteratorRecord.[[Done]] is false, then
      1. Set next to ? IteratorStepValue(iteratorRecord).
    3. If next is done, then
      1. Return ? BindingInitialization of BindingPattern with arguments A and environment.
    4. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(n)), next).
    5. Set n to n + 1.
FormalParameters : [empty]
  1. Return unused.
FormalParameters : FormalParameterList , FunctionRestParameter
  1. Perform ? IteratorBindingInitialization of FormalParameterList with arguments iteratorRecord and environment.
  2. Return ? IteratorBindingInitialization of FunctionRestParameter with arguments iteratorRecord and environment.
FormalParameterList : FormalParameterList , FormalParameter
  1. Perform ? IteratorBindingInitialization of FormalParameterList with arguments iteratorRecord and environment.
  2. Return ? IteratorBindingInitialization of FormalParameter with arguments iteratorRecord and environment.
ArrowParameters : BindingIdentifier
  1. Let v be undefined.
  2. Assert: iteratorRecord.[[Done]] is false.
  3. Let next be ? IteratorStepValue(iteratorRecord).
  4. If next is not done, then
    1. Set v to next.
  5. Return ? BindingInitialization of BindingIdentifier with arguments v and environment.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. Let formals be the ArrowFormalParameters that is covered by CoverParenthesizedExpressionAndArrowParameterList.
  2. Return ? IteratorBindingInitialization of formals with arguments iteratorRecord and environment.
AsyncArrowBindingIdentifier : BindingIdentifier
  1. Let v be undefined.
  2. Assert: iteratorRecord.[[Done]] is false.
  3. Let next be ? IteratorStepValue(iteratorRecord).
  4. If next is not done, then
    1. Set v to next.
  5. Return ? BindingInitialization of BindingIdentifier with arguments v and environment.

8.6.4 Static Semantics: AssignmentTargetType

The syntax-directed operation AssignmentTargetType takes no arguments and returns simple or invalid. It is defined piecewise over the following productions:

IdentifierReference : Identifier
  1. If IsStrict(this IdentifierReference) is true and the StringValue of Identifier is either "eval" or "arguments", return invalid.
  2. Return simple.
IdentifierReference : yield await CallExpression : CallExpression [ Expression ] CallExpression . IdentifierName CallExpression . PrivateIdentifier MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName SuperProperty MemberExpression . PrivateIdentifier
  1. Return simple.
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. Let expr be the ParenthesizedExpression that is covered by CoverParenthesizedExpressionAndArrowParameterList.
  2. Return the AssignmentTargetType of expr.
PrimaryExpression : this Literal ArrayLiteral ObjectLiteral FunctionExpression ClassExpression GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral CallExpression : CoverCallExpressionAndAsyncArrowHead SuperCall ImportCall CallExpression Arguments CallExpression TemplateLiteral NewExpression : new NewExpression MemberExpression : MemberExpression TemplateLiteral new MemberExpression Arguments NewTarget : new . target ImportMeta : import . meta LeftHandSideExpression : OptionalExpression UpdateExpression : LeftHandSideExpression ++ LeftHandSideExpression -- ++ UnaryExpression -- UnaryExpression UnaryExpression : delete UnaryExpression void UnaryExpression typeof UnaryExpression + UnaryExpression - UnaryExpression ~ UnaryExpression ! UnaryExpression AwaitExpression ExponentiationExpression : UpdateExpression ** ExponentiationExpression MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression AdditiveExpression : AdditiveExpression + MultiplicativeExpression AdditiveExpression - MultiplicativeExpression ShiftExpression : ShiftExpression << AdditiveExpression ShiftExpression >> AdditiveExpression ShiftExpression >>> AdditiveExpression RelationalExpression : RelationalExpression < ShiftExpression RelationalExpression > ShiftExpression RelationalExpression <= ShiftExpression RelationalExpression >= ShiftExpression RelationalExpression instanceof ShiftExpression RelationalExpression in ShiftExpression PrivateIdentifier in ShiftExpression EqualityExpression : EqualityExpression == RelationalExpression EqualityExpression != RelationalExpression EqualityExpression === RelationalExpression EqualityExpression !== RelationalExpression BitwiseANDExpression : BitwiseANDExpression & EqualityExpression BitwiseXORExpression : BitwiseXORExpression ^ BitwiseANDExpression BitwiseORExpression : BitwiseORExpression | BitwiseXORExpression LogicalANDExpression : LogicalANDExpression && BitwiseORExpression LogicalORExpression : LogicalORExpression || LogicalANDExpression CoalesceExpression : CoalesceExpressionHead ?? BitwiseORExpression ConditionalExpression : ShortCircuitExpression ? AssignmentExpression : AssignmentExpression AssignmentExpression : YieldExpression ArrowFunction AsyncArrowFunction LeftHandSideExpression = AssignmentExpression LeftHandSideExpression AssignmentOperator AssignmentExpression LeftHandSideExpression &&= AssignmentExpression LeftHandSideExpression ||= AssignmentExpression LeftHandSideExpression ??= AssignmentExpression Expression : Expression , AssignmentExpression
  1. Return invalid.

8.6.5 Static Semantics: PropName

The syntax-directed operation PropName takes no arguments and returns a String or empty. It is defined piecewise over the following productions:

PropertyDefinition : IdentifierReference
  1. Return the StringValue of IdentifierReference.
PropertyDefinition : ... AssignmentExpression
  1. Return empty.
PropertyDefinition : PropertyName : AssignmentExpression
  1. Return the PropName of PropertyName.
LiteralPropertyName : IdentifierName
  1. Return the StringValue of IdentifierName.
LiteralPropertyName : StringLiteral
  1. Return the SV of StringLiteral.
LiteralPropertyName : NumericLiteral
  1. Let nbr be the NumericValue of NumericLiteral.
  2. Return ! ToString(nbr).
ComputedPropertyName : [ AssignmentExpression ]
  1. Return empty.
MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } get ClassElementName ( ) { FunctionBody } set ClassElementName ( PropertySetParameterList ) { FunctionBody }
  1. Return the PropName of ClassElementName.
GeneratorMethod : * ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
  1. Return the PropName of ClassElementName.
AsyncGeneratorMethod : async * ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody }
  1. Return the PropName of ClassElementName.
ClassElement : ClassStaticBlock
  1. Return empty.
ClassElement : ;
  1. Return empty.
AsyncMethod : async ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody }
  1. Return the PropName of ClassElementName.
FieldDefinition : ClassElementName Initializeropt
  1. Return the PropName of ClassElementName.
ClassElementName : PrivateIdentifier
  1. Return empty.