14.2 Block
Syntax
14.2.1 Static Semantics: Early Errors
-
It is a Syntax Error if the
LexicallyDeclaredNames ofStatementList contains any duplicate entries. -
It is a Syntax Error if any element of the
LexicallyDeclaredNames ofStatementList also occurs in theVarDeclaredNames ofStatementList .
14.2.2 Runtime Semantics: Evaluation
- Return
empty .
- Let oldEnv be the
running execution context 's LexicalEnvironment. - Let blockEnv be
NewDeclarativeEnvironment (oldEnv). - Perform
BlockDeclarationInstantiation (StatementList , blockEnv). - Set the
running execution context 's LexicalEnvironment to blockEnv. - Let blockValue be
Completion (Evaluation ofStatementList ). - Set the
running execution context 's LexicalEnvironment to oldEnv. - Return ? blockValue.
No matter how control leaves the
- Let sl be ?
Evaluation ofStatementList . - Let s be
Completion (Evaluation ofStatementListItem ). - Return ?
UpdateEmpty (s, sl).
The value of a eval
function all return the value 1:
eval("1;;;;;")
eval("1;{}")
eval("1;var a;")
14.2.3 BlockDeclarationInstantiation ( code, env )
The abstract operation BlockDeclarationInstantiation takes arguments code (a
When a
It performs the following steps when called:
- Let declarations be the
LexicallyScopedDeclarations of code. - Let privateEnv be the
running execution context 's PrivateEnvironment. - For each element d of declarations, do
- For each element dn of the
BoundNames of d, do- If
IsConstantDeclaration of d istrue , then- Perform ! env.CreateImmutableBinding(dn,
true ).
- Perform ! env.CreateImmutableBinding(dn,
- Else,
- Perform ! env.CreateMutableBinding(dn,
false ). NOTE: This step is replaced in sectionB.3.2.6 .
- Perform ! env.CreateMutableBinding(dn,
- If
- If d is either a
FunctionDeclaration , aGeneratorDeclaration , anAsyncFunctionDeclaration , or anAsyncGeneratorDeclaration , then- Let fn be the sole element of the
BoundNames of d. - Let fo be
InstantiateFunctionObject of d with arguments env and privateEnv. - Perform ! env.InitializeBinding(fn, fo). NOTE: This step is replaced in section
B.3.2.6 .
- Let fn be the sole element of the
- For each element dn of the
- Return
unused .