8.2 Scope Analysis
8.2.1 Static Semantics: BoundNames
The
It is defined piecewise over the following productions:
- Return a
List whose sole element is theStringValue ofIdentifier .
- Return «
"yield" ».
- Return «
"await" ».
- Return the
BoundNames ofBindingList .
- Let names1 be the
BoundNames ofBindingList . - Let names2 be the
BoundNames ofLexicalBinding . - Return the
list-concatenation of names1 and names2.
- Return the
BoundNames ofBindingIdentifier .
- Return the
BoundNames ofBindingPattern .
- Let names1 be
BoundNames ofVariableDeclarationList . - Let names2 be
BoundNames ofVariableDeclaration . - Return the
list-concatenation of names1 and names2.
- Return the
BoundNames ofBindingIdentifier .
- Return the
BoundNames ofBindingPattern .
- Return a new empty
List .
- Let names1 be
BoundNames ofBindingPropertyList . - Let names2 be
BoundNames ofBindingRestProperty . - Return the
list-concatenation of names1 and names2.
- Return a new empty
List .
- Return the
BoundNames ofBindingRestElement .
- Return the
BoundNames ofBindingElementList .
- Let names1 be
BoundNames ofBindingElementList . - Let names2 be
BoundNames ofBindingRestElement . - Return the
list-concatenation of names1 and names2.
- Let names1 be
BoundNames ofBindingPropertyList . - Let names2 be
BoundNames ofBindingProperty . - Return the
list-concatenation of names1 and names2.
- Let names1 be
BoundNames ofBindingElementList . - Let names2 be
BoundNames ofBindingElisionElement . - Return the
list-concatenation of names1 and names2.
- Return
BoundNames ofBindingElement .
- Return the
BoundNames ofBindingElement .
- Return the
BoundNames ofBindingIdentifier .
- Return the
BoundNames ofBindingPattern .
- Return the
BoundNames ofForBinding .
- Return the
BoundNames ofBindingIdentifier .
- Return «
"*default*" ».
- Return a new empty
List .
- Let names1 be
BoundNames ofFormalParameterList . - Let names2 be
BoundNames ofFunctionRestParameter . - Return the
list-concatenation of names1 and names2.
- Let names1 be
BoundNames ofFormalParameterList . - Let names2 be
BoundNames ofFormalParameter . - Return the
list-concatenation of names1 and names2.
- Let formals be the
ArrowFormalParameters that iscovered byCoverParenthesizedExpressionAndArrowParameterList . - Return the
BoundNames of formals.
- Return the
BoundNames ofBindingIdentifier .
- Return «
"*default*" ».
- Return the
BoundNames ofBindingIdentifier .
- Return «
"*default*" ».
- Return the
BoundNames ofBindingIdentifier .
- Return «
"*default*" ».
- Return the
BoundNames ofBindingIdentifier .
- Return «
"*default*" ».
- Let head be the
AsyncArrowHead that iscovered byCoverCallExpressionAndAsyncArrowHead . - Return the
BoundNames of head.
- Return the
BoundNames ofImportClause .
- Return a new empty
List .
- Let names1 be the
BoundNames ofImportedDefaultBinding . - Let names2 be the
BoundNames ofNameSpaceImport . - Return the
list-concatenation of names1 and names2.
- Let names1 be the
BoundNames ofImportedDefaultBinding . - Let names2 be the
BoundNames ofNamedImports . - Return the
list-concatenation of names1 and names2.
- Return a new empty
List .
- Let names1 be the
BoundNames ofImportsList . - Let names2 be the
BoundNames ofImportSpecifier . - Return the
list-concatenation of names1 and names2.
- Return the
BoundNames ofImportedBinding .
- Return a new empty
List .
- Return the
BoundNames ofVariableStatement .
- Return the
BoundNames ofDeclaration .
- Let declarationNames be the
BoundNames ofHoistableDeclaration . - If declarationNames does not include the element
"*default*" , append"*default*" to declarationNames. - Return declarationNames.
- Let declarationNames be the
BoundNames ofClassDeclaration . - If declarationNames does not include the element
"*default*" , append"*default*" to declarationNames. - Return declarationNames.
- Return «
"*default*" ».
8.2.2 Static Semantics: DeclarationPart
The
- Return
FunctionDeclaration .
- Return
GeneratorDeclaration .
- Return
AsyncFunctionDeclaration .
- Return
AsyncGeneratorDeclaration .
- Return
ClassDeclaration .
- Return
LexicalDeclaration .
8.2.3 Static Semantics: IsConstantDeclaration
The
- Return
IsConstantDeclaration ofLetOrConst .
- Return
false .
- Return
true .
- Return
false .
- Return
false .
- Return
false .
It is not necessary to treat export default
8.2.4 Static Semantics: LexicallyDeclaredNames
The
- Return a new empty
List .
- Let names1 be
LexicallyDeclaredNames ofStatementList . - Let names2 be
LexicallyDeclaredNames ofStatementListItem . - Return the
list-concatenation of names1 and names2.
- If
Statement is , returnStatement : LabelledStatement LexicallyDeclaredNames ofLabelledStatement . - Return a new empty
List .
- Return the
BoundNames ofDeclaration .
- Return a new empty
List .
- If the first
CaseClauses is present, let names1 be theLexicallyDeclaredNames of the firstCaseClauses . - Else, let names1 be a new empty
List . - Let names2 be
LexicallyDeclaredNames ofDefaultClause . - If the second
CaseClauses is present, let names3 be theLexicallyDeclaredNames of the secondCaseClauses . - Else, let names3 be a new empty
List . - Return the
list-concatenation of names1, names2, and names3.
- Let names1 be
LexicallyDeclaredNames ofCaseClauses . - Let names2 be
LexicallyDeclaredNames ofCaseClause . - Return the
list-concatenation of names1 and names2.
- If the
StatementList is present, return theLexicallyDeclaredNames ofStatementList . - Return a new empty
List .
- If the
StatementList is present, return theLexicallyDeclaredNames ofStatementList . - Return a new empty
List .
- Return the
LexicallyDeclaredNames ofLabelledItem .
- Return a new empty
List .
- Return
BoundNames ofFunctionDeclaration .
- Return a new empty
List .
- Return
TopLevelLexicallyDeclaredNames ofStatementList .
- Return a new empty
List .
- Return the
TopLevelLexicallyDeclaredNames ofStatementList .
- Return a new empty
List .
- Return a new empty
List .
- Return a new empty
List .
- Return
TopLevelLexicallyDeclaredNames ofStatementList .
At the top level of a
The LexicallyDeclaredNames of a
- Let names1 be
LexicallyDeclaredNames ofModuleItemList . - Let names2 be
LexicallyDeclaredNames ofModuleItem . - Return the
list-concatenation of names1 and names2.
- Return the
BoundNames ofImportDeclaration .
- If
ExportDeclaration isexport
VariableStatement , return a new emptyList . - Return the
BoundNames ofExportDeclaration .
- Return
LexicallyDeclaredNames ofStatementListItem .
At the top level of a
8.2.5 Static Semantics: LexicallyScopedDeclarations
The
- Let declarations1 be
LexicallyScopedDeclarations ofStatementList . - Let declarations2 be
LexicallyScopedDeclarations ofStatementListItem . - Return the
list-concatenation of declarations1 and declarations2.
- If
Statement is , returnStatement : LabelledStatement LexicallyScopedDeclarations ofLabelledStatement . - 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 declarations1 be theLexicallyScopedDeclarations of the firstCaseClauses . - Else, let declarations1 be a new empty
List . - Let declarations2 be
LexicallyScopedDeclarations ofDefaultClause . - If the second
CaseClauses is present, let declarations3 be theLexicallyScopedDeclarations of the secondCaseClauses . - Else, let declarations3 be a new empty
List . - Return the
list-concatenation of declarations1, declarations2, and declarations3.
- Let declarations1 be
LexicallyScopedDeclarations ofCaseClauses . - Let declarations2 be
LexicallyScopedDeclarations ofCaseClause . - Return the
list-concatenation of declarations1 and declarations2.
- If the
StatementList is present, return theLexicallyScopedDeclarations ofStatementList . - Return a new empty
List .
- If the
StatementList is present, return theLexicallyScopedDeclarations ofStatementList . - Return a new empty
List .
- Return the
LexicallyScopedDeclarations ofLabelledItem .
- Return a new empty
List .
- Return «
FunctionDeclaration ».
- Return a new empty
List .
- Return the
TopLevelLexicallyScopedDeclarations ofStatementList .
- Return a new empty
List .
- Return the
TopLevelLexicallyScopedDeclarations ofStatementList .
- Return a new empty
List .
- Return a new empty
List .
- Return a new empty
List .
- Return
TopLevelLexicallyScopedDeclarations ofStatementList .
- Return a new empty
List .
- Let declarations1 be
LexicallyScopedDeclarations ofModuleItemList . - Let declarations2 be
LexicallyScopedDeclarations ofModuleItem . - Return the
list-concatenation of declarations1 and declarations2.
- 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.2.6 Static Semantics: VarDeclaredNames
The
- Return a new empty
List .
- Return a new empty
List .
- Let names1 be
VarDeclaredNames ofStatementList . - Let names2 be
VarDeclaredNames ofStatementListItem . - Return the
list-concatenation of names1 and names2.
- Return a new empty
List .
- Return
BoundNames ofVariableDeclarationList .
- Let names1 be
VarDeclaredNames of the firstStatement . - Let names2 be
VarDeclaredNames of the secondStatement . - Return the
list-concatenation of names1 and names2.
- Return the
VarDeclaredNames ofStatement .
- Return the
VarDeclaredNames ofStatement .
- Return the
VarDeclaredNames ofStatement .
- Return the
VarDeclaredNames ofStatement .
- Let names1 be
BoundNames ofVariableDeclarationList . - Let names2 be
VarDeclaredNames ofStatement . - Return the
list-concatenation of names1 and names2.
- Return the
VarDeclaredNames ofStatement .
- Return the
VarDeclaredNames ofStatement .
- Let names1 be the
BoundNames ofForBinding . - Let names2 be the
VarDeclaredNames ofStatement . - Return the
list-concatenation of names1 and names2.
This section is extended by Annex
- Return the
VarDeclaredNames ofStatement .
- Return the
VarDeclaredNames ofCaseBlock .
- Return a new empty
List .
- If the first
CaseClauses is present, let names1 be theVarDeclaredNames of the firstCaseClauses . - Else, let names1 be a new empty
List . - Let names2 be
VarDeclaredNames ofDefaultClause . - If the second
CaseClauses is present, let names3 be theVarDeclaredNames of the secondCaseClauses . - Else, let names3 be a new empty
List . - Return the
list-concatenation of names1, names2, and names3.
- Let names1 be
VarDeclaredNames ofCaseClauses . - Let names2 be
VarDeclaredNames ofCaseClause . - Return the
list-concatenation of names1 and names2.
- If the
StatementList is present, return theVarDeclaredNames ofStatementList . - Return a new empty
List .
- If the
StatementList is present, return theVarDeclaredNames ofStatementList . - Return a new empty
List .
- Return the
VarDeclaredNames ofLabelledItem .
- Return a new empty
List .
- Let names1 be
VarDeclaredNames ofBlock . - Let names2 be
VarDeclaredNames ofCatch . - Return the
list-concatenation of names1 and names2.
- Let names1 be
VarDeclaredNames ofBlock . - Let names2 be
VarDeclaredNames ofFinally . - Return the
list-concatenation of names1 and names2.
- Let names1 be
VarDeclaredNames ofBlock . - Let names2 be
VarDeclaredNames ofCatch . - Let names3 be
VarDeclaredNames ofFinally . - Return the
list-concatenation of names1, names2, and names3.
- Return the
VarDeclaredNames ofBlock .
- Return a new empty
List .
- Return
TopLevelVarDeclaredNames ofStatementList .
- Return a new empty
List .
- Return the
TopLevelVarDeclaredNames ofStatementList .
- Return a new empty
List .
- Return a new empty
List .
- Return a new empty
List .
- Return
TopLevelVarDeclaredNames ofStatementList .
- Let names1 be
VarDeclaredNames ofModuleItemList . - Let names2 be
VarDeclaredNames ofModuleItem . - Return the
list-concatenation of names1 and names2.
- Return a new empty
List .
- If
ExportDeclaration isexport
VariableStatement , returnBoundNames ofExportDeclaration . - Return a new empty
List .
8.2.7 Static Semantics: VarScopedDeclarations
The
- Return a new empty
List .
- Return a new empty
List .
- Let declarations1 be
VarScopedDeclarations ofStatementList . - Let declarations2 be
VarScopedDeclarations ofStatementListItem . - Return the
list-concatenation of declarations1 and declarations2.
- Return a new empty
List .
- Return «
VariableDeclaration ».
- Let declarations1 be
VarScopedDeclarations ofVariableDeclarationList . - Return the
list-concatenation of declarations1 and «VariableDeclaration ».
- Let declarations1 be
VarScopedDeclarations of the firstStatement . - Let declarations2 be
VarScopedDeclarations of the secondStatement . - Return the
list-concatenation of declarations1 and declarations2.
- Return the
VarScopedDeclarations ofStatement .
- Return the
VarScopedDeclarations ofStatement .
- Return the
VarScopedDeclarations ofStatement .
- Return the
VarScopedDeclarations ofStatement .
- Let declarations1 be
VarScopedDeclarations ofVariableDeclarationList . - Let declarations2 be
VarScopedDeclarations ofStatement . - Return the
list-concatenation of declarations1 and declarations2.
- Return the
VarScopedDeclarations ofStatement .
- Return the
VarScopedDeclarations ofStatement .
- Let declarations1 be «
ForBinding ». - Let declarations2 be
VarScopedDeclarations ofStatement . - Return the
list-concatenation of declarations1 and declarations2.
This section is extended by Annex
- Return the
VarScopedDeclarations ofStatement .
- Return the
VarScopedDeclarations ofCaseBlock .
- Return a new empty
List .
- If the first
CaseClauses is present, let declarations1 be theVarScopedDeclarations of the firstCaseClauses . - Else, let declarations1 be a new empty
List . - Let declarations2 be
VarScopedDeclarations ofDefaultClause . - If the second
CaseClauses is present, let declarations3 be theVarScopedDeclarations of the secondCaseClauses . - Else, let declarations3 be a new empty
List . - Return the
list-concatenation of declarations1, declarations2, and declarations3.
- Let declarations1 be
VarScopedDeclarations ofCaseClauses . - Let declarations2 be
VarScopedDeclarations ofCaseClause . - Return the
list-concatenation of declarations1 and declarations2.
- If the
StatementList is present, return theVarScopedDeclarations ofStatementList . - Return a new empty
List .
- If the
StatementList is present, return theVarScopedDeclarations ofStatementList . - Return a new empty
List .
- Return the
VarScopedDeclarations ofLabelledItem .
- Return a new empty
List .
- Let declarations1 be
VarScopedDeclarations ofBlock . - Let declarations2 be
VarScopedDeclarations ofCatch . - Return the
list-concatenation of declarations1 and declarations2.
- Let declarations1 be
VarScopedDeclarations ofBlock . - Let declarations2 be
VarScopedDeclarations ofFinally . - Return the
list-concatenation of declarations1 and declarations2.
- Let declarations1 be
VarScopedDeclarations ofBlock . - Let declarations2 be
VarScopedDeclarations ofCatch . - Let declarations3 be
VarScopedDeclarations ofFinally . - Return the
list-concatenation of declarations1, declarations2, and declarations3.
- Return the
VarScopedDeclarations ofBlock .
- Return a new empty
List .
- Return the
TopLevelVarScopedDeclarations ofStatementList .
- Return a new empty
List .
- Return the
TopLevelVarScopedDeclarations ofStatementList .
- Return a new empty
List .
- Return a new empty
List .
- Return a new empty
List .
- Return
TopLevelVarScopedDeclarations ofStatementList .
- Return a new empty
List .
- Let declarations1 be
VarScopedDeclarations ofModuleItemList . - Let declarations2 be
VarScopedDeclarations ofModuleItem . - Return the
list-concatenation of declarations1 and declarations2.
- Return a new empty
List .
- If
ExportDeclaration isexport
VariableStatement , returnVarScopedDeclarations ofVariableStatement . - Return a new empty
List .
8.2.8 Static Semantics: TopLevelLexicallyDeclaredNames
The
- Let names1 be
TopLevelLexicallyDeclaredNames ofStatementList . - Let names2 be
TopLevelLexicallyDeclaredNames ofStatementListItem . - Return the
list-concatenation of names1 and names2.
- Return a new empty
List .
- If
Declaration is , thenDeclaration : HoistableDeclaration - Return a new empty
List .
- Return a new empty
- 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.
8.2.9 Static Semantics: TopLevelLexicallyScopedDeclarations
The
- Let declarations1 be
TopLevelLexicallyScopedDeclarations ofStatementList . - Let declarations2 be
TopLevelLexicallyScopedDeclarations ofStatementListItem . - Return the
list-concatenation of declarations1 and declarations2.
- Return a new empty
List .
- If
Declaration is , thenDeclaration : HoistableDeclaration - Return a new empty
List .
- Return a new empty
- Return «
Declaration ».
8.2.10 Static Semantics: TopLevelVarDeclaredNames
The
- Let names1 be
TopLevelVarDeclaredNames ofStatementList . - Let names2 be
TopLevelVarDeclaredNames ofStatementListItem . - Return the
list-concatenation of names1 and names2.
- If
Declaration is , thenDeclaration : HoistableDeclaration - Return the
BoundNames ofHoistableDeclaration .
- Return the
- Return a new empty
List .
- If
Statement is , returnStatement : LabelledStatement TopLevelVarDeclaredNames ofStatement . - Return
VarDeclaredNames ofStatement .
At the top level of a function or script, inner function declarations are treated like var declarations.
- Return the
TopLevelVarDeclaredNames ofLabelledItem .
- If
Statement is , returnStatement : LabelledStatement TopLevelVarDeclaredNames ofStatement . - Return
VarDeclaredNames ofStatement .
- Return
BoundNames ofFunctionDeclaration .
8.2.11 Static Semantics: TopLevelVarScopedDeclarations
The
- Let declarations1 be
TopLevelVarScopedDeclarations ofStatementList . - Let declarations2 be
TopLevelVarScopedDeclarations ofStatementListItem . - Return the
list-concatenation of declarations1 and declarations2.
- If
Statement is , returnStatement : LabelledStatement TopLevelVarScopedDeclarations ofStatement . - 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 ofLabelledItem .
- If
Statement is , returnStatement : LabelledStatement TopLevelVarScopedDeclarations ofStatement . - Return
VarScopedDeclarations ofStatement .
- Return «
FunctionDeclaration ».