8 Syntax-Directed Operations
In addition to those defined in this section, specialized syntax-directed operations are defined throughout this specification.
8.1 Scope Analysis
8.1.1 Static Semantics: BoundNames
- Return a
List whose sole element is theStringValue ofIdentifier .
- Return a
List whose sole element is"yield" .
- Return a
List whose sole element is"await" .
- Return the BoundNames of
BindingList .
- Let names be the BoundNames of
BindingList . - Append to names the elements of the BoundNames of
LexicalBinding . - Return names.
- Return the BoundNames of
BindingIdentifier .
- Return the BoundNames of
BindingPattern .
- Let names be BoundNames of
VariableDeclarationList . - Append to names the elements of BoundNames of
VariableDeclaration . - Return names.
- Return the BoundNames of
BindingIdentifier .
- Return the BoundNames of
BindingPattern .
- Return a new empty
List .
- Let names be BoundNames of
BindingPropertyList . - Append to names the elements of BoundNames of
BindingRestProperty . - Return names.
- Return a new empty
List .
- Return the BoundNames of
BindingRestElement .
- Return the BoundNames of
BindingElementList .
- Let names be BoundNames of
BindingElementList . - Append to names the elements of BoundNames of
BindingRestElement . - Return names.
- Let names be BoundNames of
BindingPropertyList . - Append to names the elements of BoundNames of
BindingProperty . - Return names.
- Let names be BoundNames of
BindingElementList . - Append to names the elements of BoundNames of
BindingElisionElement . - Return names.
- Return BoundNames of
BindingElement .
- Return the BoundNames of
BindingElement .
- Return the BoundNames of
BindingIdentifier .
- Return the BoundNames of
BindingPattern .
- Return the BoundNames of
ForBinding .
- Return the BoundNames of
BindingIdentifier .
- Return «
"*default*" ».
- Return a new empty
List .
- Let names be BoundNames of
FormalParameterList . - Append to names the BoundNames of
FunctionRestParameter . - Return names.
- Let names be BoundNames of
FormalParameterList . - Append to names the BoundNames of
FormalParameter . - Return names.
- Let formals be
CoveredFormalsList ofCoverParenthesizedExpressionAndArrowParameterList . - Return the BoundNames of formals.
- Return the BoundNames of
BindingIdentifier .
- Return «
"*default*" ».
- Return the BoundNames of
BindingIdentifier .
- Return «
"*default*" ».
- Return the BoundNames of
BindingIdentifier .
- Return «
"*default*" ».
- Return the BoundNames of
BindingIdentifier .
- Return «
"*default*" ».
- Let head be
CoveredAsyncArrowHead ofCoverCallExpressionAndAsyncArrowHead . - Return the BoundNames of head.
- Return the BoundNames of
ImportClause .
- Return a new empty
List .
- Let names be the BoundNames of
ImportedDefaultBinding . - Append to names the elements of the BoundNames of
NameSpaceImport . - Return names.
- Let names be the BoundNames of
ImportedDefaultBinding . - Append to names the elements of the BoundNames of
NamedImports . - Return names.
- Return a new empty
List .
- Let names be the BoundNames of
ImportsList . - Append to names the elements of the BoundNames of
ImportSpecifier . - Return names.
- Return the BoundNames of
ImportedBinding .
- Return a new empty
List .
- Return the BoundNames of
VariableStatement .
- Return the BoundNames of
Declaration .
- Let declarationNames be the BoundNames of
HoistableDeclaration . - If declarationNames does not include the element
"*default*" , append"*default*" to declarationNames. - Return declarationNames.
- Let declarationNames be the BoundNames of
ClassDeclaration . - If declarationNames does not include the element
"*default*" , append"*default*" to declarationNames. - Return declarationNames.
- Return «
"*default*" ».
8.1.2 Static Semantics: DeclarationPart
- Return
FunctionDeclaration .
- Return
GeneratorDeclaration .
- Return
AsyncFunctionDeclaration .
- Return
AsyncGeneratorDeclaration .
- Return
ClassDeclaration .
- Return
LexicalDeclaration .
8.1.3 Static Semantics: IsConstantDeclaration
- Return IsConstantDeclaration of
LetOrConst .
- Return
false .
- Return
true .
- Return
false .
- Return
false .
- Return
false .
It is not necessary to treat export default
8.1.4 Static Semantics: LexicallyDeclaredNames
- Return a new empty
List .
- Let names be LexicallyDeclaredNames of
StatementList . - Append to names the elements of the LexicallyDeclaredNames of
StatementListItem . - Return names.
- If
Statement is , return LexicallyDeclaredNames ofStatement : LabelledStatement LabelledStatement . - Return a new empty
List .
- Return the
BoundNames ofDeclaration .
- Return a new empty
List .
- If the first
CaseClauses is present, let names be the LexicallyDeclaredNames of the firstCaseClauses . - Else, let names be a new empty
List . - Append to names the elements of the LexicallyDeclaredNames of
DefaultClause . - If the second
CaseClauses is not present, return names. - Return the result of appending to names the elements of the LexicallyDeclaredNames of the second
CaseClauses .
- Let names be LexicallyDeclaredNames of
CaseClauses . - Append to names the elements of the LexicallyDeclaredNames of
CaseClause . - Return names.
- If the
StatementList is present, return the LexicallyDeclaredNames ofStatementList . - Return a new empty
List .
- If the
StatementList is present, return the LexicallyDeclaredNames ofStatementList . - Return a new empty
List .
- Return the LexicallyDeclaredNames of
LabelledItem .
- Return a new empty
List .
- Return
BoundNames ofFunctionDeclaration .
- Return a new empty
List .
- Return
TopLevelLexicallyDeclaredNames ofStatementList .
- Return a new empty
List .
- Return a new empty
List .
- Return
TopLevelLexicallyDeclaredNames ofStatementList .
At the top level of a
The LexicallyDeclaredNames of a
- Let names be LexicallyDeclaredNames of
ModuleItemList . - Append to names the elements of the LexicallyDeclaredNames of
ModuleItem . - Return names.
- Return the
BoundNames ofImportDeclaration .
- If
ExportDeclaration isexportVariableStatement , return a new emptyList . - Return the
BoundNames ofExportDeclaration .
- Return LexicallyDeclaredNames of
StatementListItem .
At the top level of a
8.1.5 Static Semantics: LexicallyScopedDeclarations
- Let declarations be LexicallyScopedDeclarations of
StatementList . - Append to declarations the elements of the LexicallyScopedDeclarations of
StatementListItem . - Return declarations.
- If
Statement is , return LexicallyScopedDeclarations ofStatement : LabelledStatement LabelledStatement . - Return a new empty
List .
- Return a
List whose sole element isDeclarationPart ofDeclaration .
- Return a new empty
List .
- If the first
CaseClauses is present, let declarations be the LexicallyScopedDeclarations of the firstCaseClauses . - Else, let declarations be a new empty
List . - Append to declarations the elements of the LexicallyScopedDeclarations of
DefaultClause . - If the second
CaseClauses is not present, return declarations. - Return the result of appending to declarations the elements of the LexicallyScopedDeclarations of the second
CaseClauses .
- Let declarations be LexicallyScopedDeclarations of
CaseClauses . - Append to declarations the elements of the LexicallyScopedDeclarations of
CaseClause . - Return declarations.
- If the
StatementList is present, return the LexicallyScopedDeclarations ofStatementList . - Return a new empty
List .
- If the
StatementList is present, return the LexicallyScopedDeclarations ofStatementList . - Return a new empty
List .
- Return the LexicallyScopedDeclarations of
LabelledItem .
- Return a new empty
List .
- Return a
List whose sole element isFunctionDeclaration .
- Return a new empty
List .
- Return the
TopLevelLexicallyScopedDeclarations ofStatementList .
- Return a new empty
List .
- Return a new empty
List .
- Return
TopLevelLexicallyScopedDeclarations ofStatementList .
- Return a new empty
List .
- Let declarations be LexicallyScopedDeclarations of
ModuleItemList . - Append to declarations the elements of the LexicallyScopedDeclarations of
ModuleItem . - Return declarations.
- Return a new empty
List .
- Return a new empty
List .
- Return a
List whose sole element isDeclarationPart ofDeclaration .
- Return a
List whose sole element isDeclarationPart ofHoistableDeclaration .
- Return a
List whose sole element isClassDeclaration .
- Return a
List whose sole element is thisExportDeclaration .
8.1.6 Static Semantics: VarDeclaredNames
- Return a new empty
List .
- Return a new empty
List .
- Let names be VarDeclaredNames of
StatementList . - Append to names the elements of the VarDeclaredNames of
StatementListItem . - Return names.
- Return a new empty
List .
- Return
BoundNames ofVariableDeclarationList .
- Return the VarDeclaredNames of
Statement .
- Return the VarDeclaredNames of
Statement .
- Return the VarDeclaredNames of
Statement .
- Return the VarDeclaredNames of
Statement .
- Let names be
BoundNames ofVariableDeclarationList . - Append to names the elements of the VarDeclaredNames of
Statement . - Return names.
- Return the VarDeclaredNames of
Statement .
- Return the VarDeclaredNames of
Statement .
- Let names be the
BoundNames ofForBinding . - Append to names the elements of the VarDeclaredNames of
Statement . - Return names.
This section is extended by Annex
- Return the VarDeclaredNames of
Statement .
- Return the VarDeclaredNames of
CaseBlock .
- Return a new empty
List .
- If the first
CaseClauses is present, let names be the VarDeclaredNames of the firstCaseClauses . - Else, let names be a new empty
List . - Append to names the elements of the VarDeclaredNames of
DefaultClause . - If the second
CaseClauses is not present, return names. - Return the result of appending to names the elements of the VarDeclaredNames of the second
CaseClauses .
- Let names be VarDeclaredNames of
CaseClauses . - Append to names the elements of the VarDeclaredNames of
CaseClause . - Return names.
- If the
StatementList is present, return the VarDeclaredNames ofStatementList . - Return a new empty
List .
- If the
StatementList is present, return the VarDeclaredNames ofStatementList . - Return a new empty
List .
- Return the VarDeclaredNames of
LabelledItem .
- Return a new empty
List .
- Return the VarDeclaredNames of
Block .
- Return a new empty
List .
- Return
TopLevelVarDeclaredNames ofStatementList .
- Return a new empty
List .
- Return a new empty
List .
- Return
TopLevelVarDeclaredNames ofStatementList .
- Return a new empty
List .
- Let names be VarDeclaredNames of
ModuleItemList . - Append to names the elements of the VarDeclaredNames of
ModuleItem . - Return names.
- Return a new empty
List .
- If
ExportDeclaration isexportVariableStatement , returnBoundNames ofExportDeclaration . - Return a new empty
List .
8.1.7 Static Semantics: VarScopedDeclarations
- Return a new empty
List .
- Return a new empty
List .
- Let declarations be VarScopedDeclarations of
StatementList . - Append to declarations the elements of the VarScopedDeclarations of
StatementListItem . - Return declarations.
- Return a new empty
List .
- Return a
List whose sole element isVariableDeclaration .
- Let declarations be VarScopedDeclarations of
VariableDeclarationList . - Append
VariableDeclaration to declarations. - Return declarations.
- Return the VarScopedDeclarations of
Statement .
- Return the VarScopedDeclarations of
Statement .
- Return the VarScopedDeclarations of
Statement .
- Return the VarScopedDeclarations of
Statement .
- Let declarations be VarScopedDeclarations of
VariableDeclarationList . - Append to declarations the elements of the VarScopedDeclarations of
Statement . - Return declarations.
- Return the VarScopedDeclarations of
Statement .
- Return the VarScopedDeclarations of
Statement .
- Let declarations be a
List whose sole element isForBinding . - Append to declarations the elements of the VarScopedDeclarations of
Statement . - Return declarations.
This section is extended by Annex
- Return the VarScopedDeclarations of
Statement .
- Return the VarScopedDeclarations of
CaseBlock .
- Return a new empty
List .
- If the first
CaseClauses is present, let declarations be the VarScopedDeclarations of the firstCaseClauses . - Else, let declarations be a new empty
List . - Append to declarations the elements of the VarScopedDeclarations of
DefaultClause . - If the second
CaseClauses is not present, return declarations. - Return the result of appending to declarations the elements of the VarScopedDeclarations of the second
CaseClauses .
- Let declarations be VarScopedDeclarations of
CaseClauses . - Append to declarations the elements of the VarScopedDeclarations of
CaseClause . - Return declarations.
- If the
StatementList is present, return the VarScopedDeclarations ofStatementList . - Return a new empty
List .
- If the
StatementList is present, return the VarScopedDeclarations ofStatementList . - Return a new empty
List .
- Return the VarScopedDeclarations of
LabelledItem .
- Return a new empty
List .
- Return the VarScopedDeclarations of
Block .
- Return a new empty
List .
- Return the
TopLevelVarScopedDeclarations ofStatementList .
- Return a new empty
List .
- Return a new empty
List .
- Return
TopLevelVarScopedDeclarations ofStatementList .
- Return a new empty
List .
- Let declarations be VarScopedDeclarations of
ModuleItemList . - Append to declarations the elements of the VarScopedDeclarations of
ModuleItem . - Return declarations.
- Return a new empty
List .
- If
ExportDeclaration isexportVariableStatement , return VarScopedDeclarations ofVariableStatement . - Return a new empty
List .
8.1.8 Static Semantics: TopLevelLexicallyDeclaredNames
- Let names be TopLevelLexicallyDeclaredNames of
StatementList . - Append to names the elements of the TopLevelLexicallyDeclaredNames of
StatementListItem . - Return names.
- Return a new empty
List .
- If
Declaration is , thenDeclaration : HoistableDeclaration - Return « ».
- Return the
BoundNames ofDeclaration .
At the top level of a function, or script, function declarations are treated like var declarations rather than like lexical declarations.
- Return a new empty
List .
8.1.9 Static Semantics: TopLevelLexicallyScopedDeclarations
- Return a new empty
List .
- Let declarations be TopLevelLexicallyScopedDeclarations of
StatementList . - Append to declarations the elements of the TopLevelLexicallyScopedDeclarations of
StatementListItem . - Return declarations.
- Return a new empty
List .
- If
Declaration is , thenDeclaration : HoistableDeclaration - Return « ».
- Return a
List whose sole element isDeclaration .
- Return a new empty
List .
8.1.10 Static Semantics: TopLevelVarDeclaredNames
- Return a new empty
List .
- Let names be TopLevelVarDeclaredNames of
StatementList . - Append to names the elements of the TopLevelVarDeclaredNames of
StatementListItem . - Return names.
- If
Declaration is , thenDeclaration : HoistableDeclaration - Return the
BoundNames ofHoistableDeclaration .
- Return the
- Return a new empty
List .
- If
Statement is , return TopLevelVarDeclaredNames ofStatement : LabelledStatement Statement . - Return
VarDeclaredNames ofStatement .
At the top level of a function or script, inner function declarations are treated like var declarations.
- Return the TopLevelVarDeclaredNames of
LabelledItem .
- If
Statement is , return TopLevelVarDeclaredNames ofStatement : LabelledStatement Statement . - Return
VarDeclaredNames ofStatement .
- Return
BoundNames ofFunctionDeclaration .
8.1.11 Static Semantics: TopLevelVarScopedDeclarations
- Return a new empty
List .
- Let declarations be TopLevelVarScopedDeclarations of
StatementList . - Append to declarations the elements of the TopLevelVarScopedDeclarations of
StatementListItem . - Return declarations.
- If
Statement is , return TopLevelVarScopedDeclarations ofStatement : LabelledStatement Statement . - Return
VarScopedDeclarations ofStatement .
- If
Declaration is , thenDeclaration : HoistableDeclaration - Let declaration be
DeclarationPart ofHoistableDeclaration . - Return « declaration ».
- Let declaration be
- Return a new empty
List .
- Return the TopLevelVarScopedDeclarations of
LabelledItem .
- If
Statement is , return TopLevelVarScopedDeclarations ofStatement : LabelledStatement Statement . - Return
VarScopedDeclarations ofStatement .
- Return a
List whose sole element isFunctionDeclaration .
8.2 Labels
8.2.1 Static Semantics: ContainsDuplicateLabels
With parameter labelSet.
- Return
false .
- Let hasDuplicates be ContainsDuplicateLabels of
StatementList with argument labelSet. - If hasDuplicates is
true , returntrue . - Return ContainsDuplicateLabels of
StatementListItem with argument labelSet.
- Return ContainsDuplicateLabels of
Statement with argument labelSet.
- Return ContainsDuplicateLabels of
Statement with argument labelSet.
- Return ContainsDuplicateLabels of
Statement with argument labelSet.
- Return ContainsDuplicateLabels of
Statement with argument labelSet.
- Return ContainsDuplicateLabels of
Statement with argument labelSet.
This section is extended by Annex
- Return ContainsDuplicateLabels of
Statement with argument labelSet.
- Return ContainsDuplicateLabels of
CaseBlock with argument labelSet.
- Return
false .
- If the first
CaseClauses is present, then- Let hasDuplicates be ContainsDuplicateLabels of the first
CaseClauses with argument labelSet. - If hasDuplicates is
true , returntrue .
- Let hasDuplicates be ContainsDuplicateLabels of the first
- Let hasDuplicates be ContainsDuplicateLabels of
DefaultClause with argument labelSet. - If hasDuplicates is
true , returntrue . - If the second
CaseClauses is not present, returnfalse . - Return ContainsDuplicateLabels of the second
CaseClauses with argument labelSet.
- Let hasDuplicates be ContainsDuplicateLabels of
CaseClauses with argument labelSet. - If hasDuplicates is
true , returntrue . - Return ContainsDuplicateLabels of
CaseClause with argument labelSet.
- If the
StatementList is present, return ContainsDuplicateLabels ofStatementList with argument labelSet. - Return
false .
- If the
StatementList is present, return ContainsDuplicateLabels ofStatementList with argument labelSet. - Return
false .
- Let label be the
StringValue ofLabelIdentifier . - If label is an element of labelSet, return
true . - Let newLabelSet be a copy of labelSet with label appended.
- Return ContainsDuplicateLabels of
LabelledItem with argument newLabelSet.
- Return
false .
- Return ContainsDuplicateLabels of
Block with argument labelSet.
- Return
false .
- Let hasDuplicates be ContainsDuplicateLabels of
ModuleItemList with argument labelSet. - If hasDuplicates is
true , returntrue . - Return ContainsDuplicateLabels of
ModuleItem with argument labelSet.
- Return
false .
8.2.2 Static Semantics: ContainsUndefinedBreakTarget
With parameter labelSet.
- Return
false .
- Let hasUndefinedLabels be ContainsUndefinedBreakTarget of
StatementList with argument labelSet. - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedBreakTarget of
StatementListItem with argument labelSet.
- Return ContainsUndefinedBreakTarget of
Statement with argument labelSet.
- Return ContainsUndefinedBreakTarget of
Statement with argument labelSet.
- Return ContainsUndefinedBreakTarget of
Statement with argument labelSet.
- Return ContainsUndefinedBreakTarget of
Statement with argument labelSet.
- Return ContainsUndefinedBreakTarget of
Statement with argument labelSet.
This section is extended by Annex
- Return
false .
- If the
StringValue ofLabelIdentifier is not an element of labelSet, returntrue . - Return
false .
- Return ContainsUndefinedBreakTarget of
Statement with argument labelSet.
- Return ContainsUndefinedBreakTarget of
CaseBlock with argument labelSet.
- Return
false .
- If the first
CaseClauses is present, then- Let hasUndefinedLabels be ContainsUndefinedBreakTarget of the first
CaseClauses with argument labelSet. - If hasUndefinedLabels is
true , returntrue .
- Let hasUndefinedLabels be ContainsUndefinedBreakTarget of the first
- Let hasUndefinedLabels be ContainsUndefinedBreakTarget of
DefaultClause with argument labelSet. - If hasUndefinedLabels is
true , returntrue . - If the second
CaseClauses is not present, returnfalse . - Return ContainsUndefinedBreakTarget of the second
CaseClauses with argument labelSet.
- Let hasUndefinedLabels be ContainsUndefinedBreakTarget of
CaseClauses with argument labelSet. - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedBreakTarget of
CaseClause with argument labelSet.
- If the
StatementList is present, return ContainsUndefinedBreakTarget ofStatementList with argument labelSet. - Return
false .
- If the
StatementList is present, return ContainsUndefinedBreakTarget ofStatementList with argument labelSet. - Return
false .
- Let label be the
StringValue ofLabelIdentifier . - Let newLabelSet be a copy of labelSet with label appended.
- Return ContainsUndefinedBreakTarget of
LabelledItem with argument newLabelSet.
- Return
false .
- Let hasUndefinedLabels be ContainsUndefinedBreakTarget of
Block with argument labelSet. - If hasUndefinedLabels is
true , returntrue . - Let hasUndefinedLabels be ContainsUndefinedBreakTarget of
Catch with argument labelSet. - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedBreakTarget of
Finally with argument labelSet.
- Return ContainsUndefinedBreakTarget of
Block with argument labelSet.
- Return
false .
- Let hasUndefinedLabels be ContainsUndefinedBreakTarget of
ModuleItemList with argument labelSet. - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedBreakTarget of
ModuleItem with argument labelSet.
- Return
false .
8.2.3 Static Semantics: ContainsUndefinedContinueTarget
With parameters iterationSet and labelSet.
- Return
false .
- Let newIterationSet be a copy of iterationSet with all the elements of labelSet appended.
- Return ContainsUndefinedContinueTarget of
IterationStatement with arguments newIterationSet and « ».
- Let hasUndefinedLabels be ContainsUndefinedContinueTarget of
StatementList with arguments iterationSet and « ». - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedContinueTarget of
StatementListItem with arguments iterationSet and « ».
- Return ContainsUndefinedContinueTarget of
Statement with arguments iterationSet and « ».
- Return ContainsUndefinedContinueTarget of
Statement with arguments iterationSet and « ».
- Return ContainsUndefinedContinueTarget of
Statement with arguments iterationSet and « ».
- Return ContainsUndefinedContinueTarget of
Statement with arguments iterationSet and « ».
- Return ContainsUndefinedContinueTarget of
Statement with arguments iterationSet and « ».
This section is extended by Annex
- Return
false .
- If the
StringValue ofLabelIdentifier is not an element of iterationSet, returntrue . - Return
false .
- Return ContainsUndefinedContinueTarget of
Statement with arguments iterationSet and « ».
- Return ContainsUndefinedContinueTarget of
CaseBlock with arguments iterationSet and « ».
- Return
false .
- If the first
CaseClauses is present, then- Let hasUndefinedLabels be ContainsUndefinedContinueTarget of the first
CaseClauses with arguments iterationSet and « ». - If hasUndefinedLabels is
true , returntrue .
- Let hasUndefinedLabels be ContainsUndefinedContinueTarget of the first
- Let hasUndefinedLabels be ContainsUndefinedContinueTarget of
DefaultClause with arguments iterationSet and « ». - If hasUndefinedLabels is
true , returntrue . - If the second
CaseClauses is not present, returnfalse . - Return ContainsUndefinedContinueTarget of the second
CaseClauses with arguments iterationSet and « ».
- Let hasUndefinedLabels be ContainsUndefinedContinueTarget of
CaseClauses with arguments iterationSet and « ». - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedContinueTarget of
CaseClause with arguments iterationSet and « ».
- If the
StatementList is present, return ContainsUndefinedContinueTarget ofStatementList with arguments iterationSet and « ». - Return
false .
- If the
StatementList is present, return ContainsUndefinedContinueTarget ofStatementList with arguments iterationSet and « ». - Return
false .
- Let label be the
StringValue ofLabelIdentifier . - Let newLabelSet be a copy of labelSet with label appended.
- Return ContainsUndefinedContinueTarget of
LabelledItem with arguments iterationSet and newLabelSet.
- Return
false .
- Let hasUndefinedLabels be ContainsUndefinedContinueTarget of
Block with arguments iterationSet and « ». - If hasUndefinedLabels is
true , returntrue . - Let hasUndefinedLabels be ContainsUndefinedContinueTarget of
Catch with arguments iterationSet and « ». - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedContinueTarget of
Finally with arguments iterationSet and « ».
- Return ContainsUndefinedContinueTarget of
Block with arguments iterationSet and « ».
- Return
false .
- Let hasUndefinedLabels be ContainsUndefinedContinueTarget of
ModuleItemList with arguments iterationSet and « ». - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedContinueTarget of
ModuleItem with arguments iterationSet and « ».
- Return
false .
8.3 Function Name Inference
8.3.1 Static Semantics: HasName
- Let expr be
CoveredParenthesizedExpression ofCoverParenthesizedExpressionAndArrowParameterList . - If
IsFunctionDefinition of expr isfalse , returnfalse . - Return HasName of expr.
- Return
false .
- Return
true .
8.3.2 Static Semantics: IsFunctionDefinition
- Let expr be
CoveredParenthesizedExpression ofCoverParenthesizedExpressionAndArrowParameterList . - Return IsFunctionDefinition of expr.
- Return
false .
- Return
true .
8.3.3 Static Semantics: IsAnonymousFunctionDefinition ( expr )
The abstract operation IsAnonymousFunctionDefinition takes argument expr (a
- If
IsFunctionDefinition of expr isfalse , returnfalse . - Let hasName be
HasName of expr. - If hasName is
true , returnfalse . - Return
true .
8.3.4 Static Semantics: IsIdentifierRef
- Return
true .
- Return
false .
8.3.5 Runtime Semantics: NamedEvaluation
With parameter name.
- Let expr be
CoveredParenthesizedExpression ofCoverParenthesizedExpressionAndArrowParameterList . - Return the result of performing NamedEvaluation for expr with argument name.
Assert :IsAnonymousFunctionDefinition (Expression ) istrue .- Return the result of performing NamedEvaluation for
Expression with argument name.
- Return
InstantiateOrdinaryFunctionExpression ofFunctionExpression with argument name.
- Return
InstantiateGeneratorFunctionExpression ofGeneratorExpression with argument name.
- Return
InstantiateAsyncGeneratorFunctionExpression ofAsyncGeneratorExpression with argument name.
- Return
InstantiateAsyncFunctionExpression ofAsyncFunctionExpression with argument name.
- Return
InstantiateArrowFunctionExpression ofArrowFunction with argument name.
- Return
InstantiateAsyncArrowFunctionExpression ofAsyncArrowFunction with argument name.
- Let value be the result of
ClassDefinitionEvaluation ofClassTail with argumentsundefined and name. ReturnIfAbrupt (value).Set value.[[SourceText]] to thesource text matched by ClassExpression .- Return value.
8.4 Contains
8.4.1 Static Semantics: Contains
With parameter symbol.
Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of Contains:
- For each child node child of this
Parse Node , do- If child is an instance of symbol, return
true . - If child is an instance of a nonterminal, then
- Let contained be the result of child Contains symbol.
- If contained is
true , returntrue .
- If child is an instance of symbol, return
- Return
false .
- Return
false .
Static semantic rules that depend upon substructure generally do not look into function definitions.
- If symbol is
ClassBody , returntrue . - If symbol is
ClassHeritage , then- If
ClassHeritage is present, returntrue ; otherwise returnfalse .
- If
- Let inHeritage be
ClassHeritage Contains symbol. - If inHeritage is
true , returntrue . - Return the result of
ComputedPropertyContains forClassBody with argument symbol.
Static semantic rules that depend upon substructure generally do not look into class bodies except for
- If symbol is not one of
NewTarget ,SuperProperty ,SuperCall ,superorthis, returnfalse . - If
ArrowParameters Contains symbol istrue , returntrue . - Return
ConciseBody Contains symbol.
- Let formals be
CoveredFormalsList ofCoverParenthesizedExpressionAndArrowParameterList . - Return formals Contains symbol.
- If symbol is not one of
NewTarget ,SuperProperty ,SuperCall ,super, orthis, returnfalse . - Return
AsyncConciseBody Contains symbol.
- If symbol is not one of
NewTarget ,SuperProperty ,SuperCall ,super, orthis, returnfalse . - Let head be
CoveredAsyncArrowHead ofCoverCallExpressionAndAsyncArrowHead . - If head Contains symbol is
true , returntrue . - Return
AsyncConciseBody Contains symbol.
Contains is used to detect new.target, this, and super usage within an
- If symbol is
MethodDefinition , returntrue . - Return the result of
ComputedPropertyContains forMethodDefinition with argument symbol.
- Return
false .
- If
MemberExpression Contains symbol istrue , returntrue . - Return
false .
- If symbol is the
ReservedWord super, returntrue . - Return
false .
- If
CallExpression Contains symbol istrue , returntrue . - Return
false .
- Return
false .
- If
OptionalChain Contains symbol istrue , returntrue . - Return
false .
8.4.2 Static Semantics: ComputedPropertyContains
With parameter symbol.
- Return
false .
- Return the result of
ComputedPropertyName Contains symbol.
- Return the result of ComputedPropertyContains for
PropertyName with argument symbol.
- Return the result of ComputedPropertyContains for
PropertyName with argument symbol.
- Return the result of ComputedPropertyContains for
PropertyName with argument symbol.
- Let inList be ComputedPropertyContains of
ClassElementList with argument symbol. - If inList is
true , returntrue . - Return the result of ComputedPropertyContains for
ClassElement with argument symbol.
- Return
false .
- Return the result of ComputedPropertyContains for
PropertyName with argument symbol.
8.5 Miscellaneous
These operations are used in multiple places throughout the specification.
8.5.1 Runtime Semantics: InstantiateFunctionObject
With parameter scope.
- Return ?
InstantiateOrdinaryFunctionObject ofFunctionDeclaration with argument scope.
- Return ?
InstantiateGeneratorFunctionObject ofGeneratorDeclaration with argument scope.
- Return ?
InstantiateAsyncGeneratorFunctionObject ofAsyncGeneratorDeclaration with argument scope.
- Return ?
InstantiateAsyncFunctionObject ofAsyncFunctionDeclaration with argument scope.
8.5.2 Runtime Semantics: BindingInitialization
With parameters value and environment.
var statements and formal parameter lists of some non-strict functions (See
- Let name be
StringValue ofIdentifier . - Return ?
InitializeBoundName (name, value, environment).
- Return ?
InitializeBoundName ("yield" , value, environment).
- Return ?
InitializeBoundName ("await" , value, environment).
- Perform ?
RequireObjectCoercible (value). - Return the result of performing BindingInitialization for
ObjectBindingPattern using value and environment as arguments.
- Let iteratorRecord be ?
GetIterator (value). - Let result be
IteratorBindingInitialization ofArrayBindingPattern with arguments iteratorRecord and environment. - If iteratorRecord.[[Done]] is
false , return ?IteratorClose (iteratorRecord, result). - Return result.
- Return
NormalCompletion (empty ).
- Perform ?
PropertyBindingInitialization forBindingPropertyList using value and environment as the arguments. - Return
NormalCompletion (empty ).
- Let excludedNames be a new empty
List . - Return the result of performing
RestBindingInitialization ofBindingRestProperty with value, environment, and excludedNames as the arguments.
- Let excludedNames be ?
PropertyBindingInitialization ofBindingPropertyList with arguments value and environment. - Return the result of performing
RestBindingInitialization ofBindingRestProperty with arguments value, environment, and excludedNames.
8.5.2.1 InitializeBoundName ( name, value, environment )
The abstract operation InitializeBoundName takes arguments name, value, and environment. It performs the following steps when called:
Assert :Type (name) is String.- If environment is not
undefined , then- Perform environment.InitializeBinding(name, value).
- Return
NormalCompletion (undefined ).
- Else,
- Let lhs be
ResolveBinding (name). - Return ?
PutValue (lhs, value).
- Let lhs be
8.5.3 Runtime Semantics: IteratorBindingInitialization
With parameters iteratorRecord and environment.
When
- Return
NormalCompletion (empty ).
- Return the result of performing
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.
- If
Elision is present, then- Perform ?
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.
- Perform ?
- Return the result of performing IteratorBindingInitialization for
BindingRestElement with iteratorRecord and environment as arguments.
- Perform ? IteratorBindingInitialization for
BindingElementList with iteratorRecord and environment as arguments. - Return the result of performing
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.
- Perform ? IteratorBindingInitialization for
BindingElementList with iteratorRecord and environment as arguments. - If
Elision is present, then- Perform ?
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.
- Perform ?
- Return the result of performing IteratorBindingInitialization for
BindingRestElement with iteratorRecord and environment as arguments.
- Perform ? IteratorBindingInitialization for
BindingElementList with iteratorRecord and environment as arguments. - Return the result of performing IteratorBindingInitialization for
BindingElisionElement using iteratorRecord and environment as arguments.
- Perform ?
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument. - Return the result of performing IteratorBindingInitialization of
BindingElement with iteratorRecord and environment as the arguments.
- Let bindingId be
StringValue ofBindingIdentifier . - Let lhs be ?
ResolveBinding (bindingId, environment). - If iteratorRecord.[[Done]] is
false , then- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue . - Else,
- Let v be
IteratorValue (next). - If v is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (v).
- Let v be
- Let next be
- If iteratorRecord.[[Done]] is
true , let v beundefined . - If
Initializer is present and v isundefined , then- If
IsAnonymousFunctionDefinition (Initializer ) istrue , thenSet v to the result of performingNamedEvaluation forInitializer with argument bindingId.
- Else,
- Let defaultValue be the result of evaluating
Initializer . Set v to ?GetValue (defaultValue).
- Let defaultValue be the result of evaluating
- If
- If environment is
undefined , return ?PutValue (lhs, v). - Return
InitializeReferencedBinding (lhs, v).
- If iteratorRecord.[[Done]] is
false , then- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue . - Else,
- Let v be
IteratorValue (next). - If v is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (v).
- Let v be
- Let next be
- If iteratorRecord.[[Done]] is
true , let v beundefined . - If
Initializer is present and v isundefined , then- Let defaultValue be the result of evaluating
Initializer . Set v to ?GetValue (defaultValue).
- Let defaultValue be the result of evaluating
- Return the result of performing
BindingInitialization ofBindingPattern with v and environment as the arguments.
- Let lhs be ?
ResolveBinding (StringValue ofBindingIdentifier , environment). - Let A be !
ArrayCreate (0). - Let n be 0.
- Repeat,
- If iteratorRecord.[[Done]] is
false , then- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue .
- Let next be
- If iteratorRecord.[[Done]] is
true , then- If environment is
undefined , return ?PutValue (lhs, A). - Return
InitializeReferencedBinding (lhs, A).
- If environment is
- Let nextValue be
IteratorValue (next). - If nextValue is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (nextValue).- Perform !
CreateDataPropertyOrThrow (A, !ToString (𝔽(n)), nextValue). Set n to n + 1.
- If iteratorRecord.[[Done]] is
- Let A be !
ArrayCreate (0). - Let n be 0.
- Repeat,
- If iteratorRecord.[[Done]] is
false , then- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue .
- Let next be
- If iteratorRecord.[[Done]] is
true , then- Return the result of performing
BindingInitialization ofBindingPattern with A and environment as the arguments.
- Return the result of performing
- Let nextValue be
IteratorValue (next). - If nextValue is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (nextValue).- Perform !
CreateDataPropertyOrThrow (A, !ToString (𝔽(n)), nextValue). Set n to n + 1.
- If iteratorRecord.[[Done]] is
- Return
NormalCompletion (empty ).
- Perform ? IteratorBindingInitialization for
FormalParameterList using iteratorRecord and environment as the arguments. - Return the result of performing IteratorBindingInitialization for
FunctionRestParameter using iteratorRecord and environment as the arguments.
- Perform ? IteratorBindingInitialization for
FormalParameterList using iteratorRecord and environment as the arguments. - Return the result of performing IteratorBindingInitialization for
FormalParameter using iteratorRecord and environment as the arguments.
Assert : iteratorRecord.[[Done]] isfalse .- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue . - Else,
- Let v be
IteratorValue (next). - If v is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (v).
- Let v be
- If iteratorRecord.[[Done]] is
true , let v beundefined . - Return the result of performing
BindingInitialization forBindingIdentifier using v and environment as the arguments.
- Let formals be
CoveredFormalsList ofCoverParenthesizedExpressionAndArrowParameterList . - Return IteratorBindingInitialization of formals with arguments iteratorRecord and environment.
Assert : iteratorRecord.[[Done]] isfalse .- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue . - Else,
- Let v be
IteratorValue (next). - If v is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (v).
- Let v be
- If iteratorRecord.[[Done]] is
true , let v beundefined . - Return the result of performing
BindingInitialization forBindingIdentifier using v and environment as the arguments.
8.5.4 Static Semantics: AssignmentTargetType
- If this
IdentifierReference is contained instrict mode code andStringValue ofIdentifier is"eval" or"arguments" , returninvalid . - Return
simple .
- Return
simple .
- Let expr be
CoveredParenthesizedExpression ofCoverParenthesizedExpressionAndArrowParameterList . - Return AssignmentTargetType of expr.
- Return
invalid .
8.5.5 Static Semantics: PropName
- Return
StringValue ofIdentifierReference .
- Return
empty .
- Return PropName of
PropertyName .
- Return
StringValue ofIdentifierName .
- Return the
SV ofStringLiteral .
- Let nbr be the
NumericValue ofNumericLiteral . - Return !
ToString (nbr).
- Return
empty .
- Return PropName of
PropertyName .
- Return PropName of
PropertyName .
- Return PropName of
PropertyName .
- Return
empty .
- Return PropName of
PropertyName .