8.1 Scope Analysis

8.1.1 Static Semantics: BoundNames

Note

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

BindingIdentifier : Identifier
  1. Return a List whose sole element is the StringValue of Identifier.
BindingIdentifier : yield
  1. Return a List whose sole element is "yield".
BindingIdentifier : await
  1. Return a List whose sole element is "await".
LexicalDeclaration : LetOrConst BindingList ;
  1. Return the BoundNames of BindingList.
BindingList : BindingList , LexicalBinding
  1. Let names be the BoundNames of BindingList.
  2. Append to names the elements of the BoundNames of LexicalBinding.
  3. Return names.
LexicalBinding : BindingIdentifier Initializeropt
  1. Return the BoundNames of BindingIdentifier.
LexicalBinding : BindingPattern Initializer
  1. Return the BoundNames of BindingPattern.
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. Let names be BoundNames of VariableDeclarationList.
  2. Append to names the elements of BoundNames of VariableDeclaration.
  3. Return names.
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 names be BoundNames of BindingPropertyList.
  2. Append to names the elements of BoundNames of BindingRestProperty.
  3. Return names.
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 names be BoundNames of BindingElementList.
  2. Append to names the elements of BoundNames of BindingRestElement.
  3. Return names.
BindingPropertyList : BindingPropertyList , BindingProperty
  1. Let names be BoundNames of BindingPropertyList.
  2. Append to names the elements of BoundNames of BindingProperty.
  3. Return names.
BindingElementList : BindingElementList , BindingElisionElement
  1. Let names be BoundNames of BindingElementList.
  2. Append to names the elements of BoundNames of BindingElisionElement.
  3. Return names.
BindingElisionElement : Elisionopt BindingElement
  1. Return 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 names be BoundNames of FormalParameterList.
  2. Append to names the BoundNames of FunctionRestParameter.
  3. Return names.
FormalParameterList : FormalParameterList , FormalParameter
  1. Let names be BoundNames of FormalParameterList.
  2. Append to names the BoundNames of FormalParameter.
  3. Return names.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. Let formals be CoveredFormalsList of 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 CoveredAsyncArrowHead of 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 names be the BoundNames of ImportedDefaultBinding.
  2. Append to names the elements of the BoundNames of NameSpaceImport.
  3. Return names.
ImportClause : ImportedDefaultBinding , NamedImports
  1. Let names be the BoundNames of ImportedDefaultBinding.
  2. Append to names the elements of the BoundNames of NamedImports.
  3. Return names.
NamedImports : { }
  1. Return a new empty List.
ImportsList : ImportsList , ImportSpecifier
  1. Let names be the BoundNames of ImportsList.
  2. Append to names the elements of the BoundNames of ImportSpecifier.
  3. Return names.
ImportSpecifier : IdentifierName 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.1.2 Static Semantics: DeclarationPart

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.1.3 Static Semantics: IsConstantDeclaration

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.1.4 Static Semantics: LexicallyDeclaredNames

Block : { }
  1. Return a new empty List.
StatementList : StatementList StatementListItem
  1. Let names be LexicallyDeclaredNames of StatementList.
  2. Append to names the elements of the LexicallyDeclaredNames of StatementListItem.
  3. Return names.
StatementListItem : Statement
  1. If Statement is Statement : LabelledStatement , return 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 names be the LexicallyDeclaredNames of the first CaseClauses.
  2. Else, let names be a new empty List.
  3. Append to names the elements of the LexicallyDeclaredNames of DefaultClause.
  4. If the second CaseClauses is not present, return names.
  5. Return the result of appending to names the elements of the LexicallyDeclaredNames of the second CaseClauses.
CaseClauses : CaseClauses CaseClause
  1. Let names be LexicallyDeclaredNames of CaseClauses.
  2. Append to names the elements of the LexicallyDeclaredNames of CaseClause.
  3. Return names.
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 BoundNames of FunctionDeclaration.
FunctionStatementList : [empty]
  1. Return a new empty List.
FunctionStatementList : StatementList
  1. Return TopLevelLexicallyDeclaredNames of StatementList.
ConciseBody : ExpressionBody
  1. Return a new empty List.
AsyncConciseBody : ExpressionBody
  1. Return a new empty List.
ScriptBody : StatementList
  1. Return 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 names be LexicallyDeclaredNames of ModuleItemList.
  2. Append to names the elements of the LexicallyDeclaredNames of ModuleItem.
  3. Return names.
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 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.1.5 Static Semantics: LexicallyScopedDeclarations

StatementList : StatementList StatementListItem
  1. Let declarations be LexicallyScopedDeclarations of StatementList.
  2. Append to declarations the elements of the LexicallyScopedDeclarations of StatementListItem.
  3. Return declarations.
StatementListItem : Statement
  1. If Statement is Statement : LabelledStatement , return LexicallyScopedDeclarations of LabelledStatement.
  2. Return a new empty List.
StatementListItem : Declaration
  1. Return a List whose sole element is DeclarationPart of Declaration.
CaseBlock : { }
  1. Return a new empty List.
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. If the first CaseClauses is present, let declarations be the LexicallyScopedDeclarations of the first CaseClauses.
  2. Else, let declarations be a new empty List.
  3. Append to declarations the elements of the LexicallyScopedDeclarations of DefaultClause.
  4. If the second CaseClauses is not present, return declarations.
  5. Return the result of appending to declarations the elements of the LexicallyScopedDeclarations of the second CaseClauses.
CaseClauses : CaseClauses CaseClause
  1. Let declarations be LexicallyScopedDeclarations of CaseClauses.
  2. Append to declarations the elements of the LexicallyScopedDeclarations of CaseClause.
  3. Return declarations.
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 a List whose sole element is FunctionDeclaration.
FunctionStatementList : [empty]
  1. Return a new empty List.
FunctionStatementList : StatementList
  1. Return the TopLevelLexicallyScopedDeclarations of StatementList.
ConciseBody : ExpressionBody
  1. Return a new empty List.
AsyncConciseBody : ExpressionBody
  1. Return a new empty List.
ScriptBody : StatementList
  1. Return TopLevelLexicallyScopedDeclarations of StatementList.
Module : [empty]
  1. Return a new empty List.
ModuleItemList : ModuleItemList ModuleItem
  1. Let declarations be LexicallyScopedDeclarations of ModuleItemList.
  2. Append to declarations the elements of the LexicallyScopedDeclarations of ModuleItem.
  3. Return declarations.
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 DeclarationPart of Declaration.
ExportDeclaration : export default HoistableDeclaration
  1. Return a List whose sole element is 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.1.6 Static Semantics: VarDeclaredNames

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 names be VarDeclaredNames of StatementList.
  2. Append to names the elements of the VarDeclaredNames of StatementListItem.
  3. Return names.
StatementListItem : Declaration
  1. Return a new empty List.
VariableStatement : var VariableDeclarationList ;
  1. Return BoundNames of VariableDeclarationList.
IfStatement : if ( Expression ) Statement else Statement
  1. Let names be VarDeclaredNames of the first Statement.
  2. Append to names the elements of the VarDeclaredNames of the second Statement.
  3. Return names.
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 names be BoundNames of VariableDeclarationList.
  2. Append to names the elements of the VarDeclaredNames of Statement.
  3. Return names.
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 names be the BoundNames of ForBinding.
  2. Append to names the elements of the VarDeclaredNames of Statement.
  3. Return names.
Note

This section is extended by Annex B.3.6.

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 names be the VarDeclaredNames of the first CaseClauses.
  2. Else, let names be a new empty List.
  3. Append to names the elements of the VarDeclaredNames of DefaultClause.
  4. If the second CaseClauses is not present, return names.
  5. Return the result of appending to names the elements of the VarDeclaredNames of the second CaseClauses.
CaseClauses : CaseClauses CaseClause
  1. Let names be VarDeclaredNames of CaseClauses.
  2. Append to names the elements of the VarDeclaredNames of CaseClause.
  3. Return names.
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 names be VarDeclaredNames of Block.
  2. Append to names the elements of the VarDeclaredNames of Catch.
  3. Return names.
TryStatement : try Block Finally
  1. Let names be VarDeclaredNames of Block.
  2. Append to names the elements of the VarDeclaredNames of Finally.
  3. Return names.
TryStatement : try Block Catch Finally
  1. Let names be VarDeclaredNames of Block.
  2. Append to names the elements of the VarDeclaredNames of Catch.
  3. Append to names the elements of the VarDeclaredNames of Finally.
  4. Return names.
Catch : catch ( CatchParameter ) Block
  1. Return the VarDeclaredNames of Block.
FunctionStatementList : [empty]
  1. Return a new empty List.
FunctionStatementList : StatementList
  1. Return TopLevelVarDeclaredNames of StatementList.
ConciseBody : ExpressionBody
  1. Return a new empty List.
AsyncConciseBody : ExpressionBody
  1. Return a new empty List.
ScriptBody : StatementList
  1. Return TopLevelVarDeclaredNames of StatementList.
Module : [empty]
  1. Return a new empty List.
ModuleItemList : ModuleItemList ModuleItem
  1. Let names be VarDeclaredNames of ModuleItemList.
  2. Append to names the elements of the VarDeclaredNames of ModuleItem.
  3. Return names.
ModuleItem : ImportDeclaration
  1. Return a new empty List.
ModuleItem : ExportDeclaration
  1. If ExportDeclaration is export VariableStatement, return BoundNames of ExportDeclaration.
  2. Return a new empty List.

8.1.7 Static Semantics: VarScopedDeclarations

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 declarations be VarScopedDeclarations of StatementList.
  2. Append to declarations the elements of the VarScopedDeclarations of StatementListItem.
  3. Return declarations.
StatementListItem : Declaration
  1. Return a new empty List.
VariableDeclarationList : VariableDeclaration
  1. Return a List whose sole element is VariableDeclaration.
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. Let declarations be VarScopedDeclarations of VariableDeclarationList.
  2. Append VariableDeclaration to declarations.
  3. Return declarations.
IfStatement : if ( Expression ) Statement else Statement
  1. Let declarations be VarScopedDeclarations of the first Statement.
  2. Append to declarations the elements of the VarScopedDeclarations of the second Statement.
  3. Return declarations.
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 declarations be VarScopedDeclarations of VariableDeclarationList.
  2. Append to declarations the elements of the VarScopedDeclarations of Statement.
  3. Return declarations.
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 declarations be a List whose sole element is ForBinding.
  2. Append to declarations the elements of the VarScopedDeclarations of Statement.
  3. Return declarations.
Note

This section is extended by Annex B.3.6.

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 declarations be the VarScopedDeclarations of the first CaseClauses.
  2. Else, let declarations be a new empty List.
  3. Append to declarations the elements of the VarScopedDeclarations of DefaultClause.
  4. If the second CaseClauses is not present, return declarations.
  5. Return the result of appending to declarations the elements of the VarScopedDeclarations of the second CaseClauses.
CaseClauses : CaseClauses CaseClause
  1. Let declarations be VarScopedDeclarations of CaseClauses.
  2. Append to declarations the elements of the VarScopedDeclarations of CaseClause.
  3. Return declarations.
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 declarations be VarScopedDeclarations of Block.
  2. Append to declarations the elements of the VarScopedDeclarations of Catch.
  3. Return declarations.
TryStatement : try Block Finally
  1. Let declarations be VarScopedDeclarations of Block.
  2. Append to declarations the elements of the VarScopedDeclarations of Finally.
  3. Return declarations.
TryStatement : try Block Catch Finally
  1. Let declarations be VarScopedDeclarations of Block.
  2. Append to declarations the elements of the VarScopedDeclarations of Catch.
  3. Append to declarations the elements of the VarScopedDeclarations of Finally.
  4. Return declarations.
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.
ConciseBody : ExpressionBody
  1. Return a new empty List.
AsyncConciseBody : ExpressionBody
  1. Return a new empty List.
ScriptBody : StatementList
  1. Return TopLevelVarScopedDeclarations of StatementList.
Module : [empty]
  1. Return a new empty List.
ModuleItemList : ModuleItemList ModuleItem
  1. Let declarations be VarScopedDeclarations of ModuleItemList.
  2. Append to declarations the elements of the VarScopedDeclarations of ModuleItem.
  3. Return declarations.
ModuleItem : ImportDeclaration
  1. Return a new empty List.
ModuleItem : ExportDeclaration
  1. If ExportDeclaration is export VariableStatement, return VarScopedDeclarations of VariableStatement.
  2. Return a new empty List.

8.1.8 Static Semantics: TopLevelLexicallyDeclaredNames

StatementList : StatementList StatementListItem
  1. Let names be TopLevelLexicallyDeclaredNames of StatementList.
  2. Append to names the elements of the TopLevelLexicallyDeclaredNames of StatementListItem.
  3. Return names.
StatementListItem : Statement
  1. Return a new empty List.
StatementListItem : Declaration
  1. If Declaration is Declaration : HoistableDeclaration , then
    1. Return « ».
  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.

LabelledStatement : LabelIdentifier : LabelledItem
  1. Return a new empty List.

8.1.9 Static Semantics: TopLevelLexicallyScopedDeclarations

Block : { }
  1. Return a new empty List.
StatementList : StatementList StatementListItem
  1. Let declarations be TopLevelLexicallyScopedDeclarations of StatementList.
  2. Append to declarations the elements of the TopLevelLexicallyScopedDeclarations of StatementListItem.
  3. Return declarations.
StatementListItem : Statement
  1. Return a new empty List.
StatementListItem : Declaration
  1. If Declaration is Declaration : HoistableDeclaration , then
    1. Return « ».
  2. Return a List whose sole element is Declaration.
LabelledStatement : LabelIdentifier : LabelledItem
  1. Return a new empty List.

8.1.10 Static Semantics: TopLevelVarDeclaredNames

Block : { }
  1. Return a new empty List.
StatementList : StatementList StatementListItem
  1. Let names be TopLevelVarDeclaredNames of StatementList.
  2. Append to names the elements of the TopLevelVarDeclaredNames of StatementListItem.
  3. Return names.
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 TopLevelVarDeclaredNames of Statement.
  2. Return 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 TopLevelVarDeclaredNames of Statement.
  2. Return VarDeclaredNames of Statement.
LabelledItem : FunctionDeclaration
  1. Return BoundNames of FunctionDeclaration.

8.1.11 Static Semantics: TopLevelVarScopedDeclarations

Block : { }
  1. Return a new empty List.
StatementList : StatementList StatementListItem
  1. Let declarations be TopLevelVarScopedDeclarations of StatementList.
  2. Append to declarations the elements of the TopLevelVarScopedDeclarations of StatementListItem.
  3. Return declarations.
StatementListItem : Statement
  1. If Statement is Statement : LabelledStatement , return TopLevelVarScopedDeclarations of Statement.
  2. Return VarScopedDeclarations of Statement.
StatementListItem : Declaration
  1. If Declaration is Declaration : HoistableDeclaration , then
    1. Let declaration be 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 TopLevelVarScopedDeclarations of Statement.
  2. Return VarScopedDeclarations of Statement.
LabelledItem : FunctionDeclaration
  1. Return a List whose sole element is FunctionDeclaration.