B.3 Other Additional Features
B.3.1 __proto__ Property Names in Object Initializers
The following Early Error rule is added to those in
- when
ObjectLiteral appears in a context whereObjectAssignmentPattern is required, - when initially parsing a
CoverParenthesizedExpressionAndArrowParameterList or aCoverCallExpressionAndAsyncArrowHead , or - when parsing text for
JSON.parse .
-
It is a Syntax Error if
PropertyNameList ofPropertyDefinitionList contains any duplicate entries for"__proto__" and at least two of those entries were obtained from productions of the form .PropertyDefinition : PropertyName : AssignmentExpression
The
In
is replaced with the following definition:
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- If propKey is the String value
"__proto__" and ifIsComputedPropertyKey (PropertyName ) isfalse , then- Let isProtoSetter be
true .
- Let isProtoSetter be
- Else,
- Let isProtoSetter be
false .
- Let isProtoSetter be
- If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue and isProtoSetter isfalse , then- Let propValue be ?
NamedEvaluation ofAssignmentExpression with argument propKey.
- Let propValue be ?
- Else,
- Let exprValueRef be the result of evaluating
AssignmentExpression . - Let propValue be ?
GetValue (exprValueRef).
- Let exprValueRef be the result of evaluating
- If isProtoSetter is
true , then- If
Type (propValue) is either Object or Null, then- Return object.[[SetPrototypeOf]](propValue).
- Return
NormalCompletion (empty ).
- If
Assert : enumerable istrue .Assert : object is an ordinary, extensible object with no non-configurable properties.- Return !
CreateDataPropertyOrThrow (object, propKey, propValue).
B.3.2 Labelled Function Declarations
Prior to ECMAScript 2015, the specification of
- It is a Syntax Error if any strict mode source code matches this rule.
The
B.3.3 Block-Level Function Declarations Web Legacy Compatibility Semantics
Prior to ECMAScript 2015, the ECMAScript specification did not define the occurrence of a
-
A function is declared and only referenced within a single block
-
One or more
FunctionDeclaration s whoseBindingIdentifier is the name f occur within the function code of an enclosing function g and that declaration is nested within aBlock . -
No other declaration of f that is not a
var
declaration occurs within the function code of g -
All occurrences of f as an
IdentifierReference are within theStatementList of theBlock containing the declaration of f.
-
One or more
-
A function is declared and possibly used within a single
Block but also referenced by an inner function definition that is not contained within that sameBlock .-
One or more
FunctionDeclaration s whoseBindingIdentifier is the name f occur within the function code of an enclosing function g and that declaration is nested within aBlock . -
No other declaration of f that is not a
var
declaration occurs within the function code of g -
There may be occurrences of f as an
IdentifierReference within theStatementList of theBlock containing the declaration of f. -
There is at least one occurrence of f as an
IdentifierReference within another function h that is nested within g and no other declaration of f shadows the references to f from within h. - All invocations of h occur after the declaration of f has been evaluated.
-
One or more
-
A function is declared and possibly used within a single block but also referenced within subsequent blocks.
-
One or more
FunctionDeclaration whoseBindingIdentifier is the name f occur within the function code of an enclosing function g and that declaration is nested within aBlock . -
No other declaration of f that is not a
var
declaration occurs within the function code of g -
There may be occurrences of f as an
IdentifierReference within theStatementList of theBlock containing the declaration of f. -
There is at least one occurrence of f as an
IdentifierReference within the function code of g that lexically follows theBlock containing the declaration of f.
-
One or more
The first use case is interoperable with the semantics of
ECMAScript 2015 interoperability for the second and third use cases requires the following extensions to the clause
If an ECMAScript implementation has a mechanism for reporting diagnostic warning messages, a warning should be produced when code contains a
B.3.3.1 Changes to FunctionDeclarationInstantiation
During
- If strict is
false , then- For each
FunctionDeclaration f that is directly contained in theStatementList of aBlock ,CaseClause , orDefaultClause , do- Let F be
StringValue of theBindingIdentifier of f. - If replacing the
FunctionDeclaration f with aVariableStatement that has F as aBindingIdentifier would not produce any Early Errors for func and F is not an element of parameterNames, then- NOTE: A var binding for F is only instantiated here if it is neither a VarDeclaredName, the name of a formal parameter, or another
FunctionDeclaration . - If initializedBindings does not contain F and F is not
"arguments" , then- Perform ! varEnv.CreateMutableBinding(F,
false ). - Perform varEnv.InitializeBinding(F,
undefined ). - Append F to instantiatedVarNames.
- Perform ! varEnv.CreateMutableBinding(F,
- When the
FunctionDeclaration f is evaluated, perform the following steps in place of theFunctionDeclaration Evaluation algorithm provided in15.2.6 :- Let fenv be the
running execution context 's VariableEnvironment. - Let benv be the
running execution context 's LexicalEnvironment. - Let fobj be ! benv.GetBindingValue(F,
false ). - Perform ! fenv.SetMutableBinding(F, fobj,
false ). - Return
NormalCompletion (empty ).
- Let fenv be the
- NOTE: A var binding for F is only instantiated here if it is neither a VarDeclaredName, the name of a formal parameter, or another
- Let F be
- For each
B.3.3.2 Changes to GlobalDeclarationInstantiation
During
- Let strict be
IsStrict of script. - If strict is
false , then- Let declaredFunctionOrVarNames be a new empty
List . - Append to declaredFunctionOrVarNames the elements of declaredFunctionNames.
- Append to declaredFunctionOrVarNames the elements of declaredVarNames.
- For each
FunctionDeclaration f that is directly contained in theStatementList of aBlock ,CaseClause , orDefaultClause Contained within script, do- Let F be
StringValue of theBindingIdentifier of f. - If replacing the
FunctionDeclaration f with aVariableStatement that has F as aBindingIdentifier would not produce any Early Errors for script, then- If env.HasLexicalDeclaration(F) is
false , then- Let fnDefinable be ? env.CanDeclareGlobalVar(F).
- If fnDefinable is
true , then- NOTE: A var binding for F is only instantiated here if it is neither a VarDeclaredName nor the name of another
FunctionDeclaration . - If declaredFunctionOrVarNames does not contain F, then
- Perform ? env.CreateGlobalVarBinding(F,
false ). - Append F to declaredFunctionOrVarNames.
- Perform ? env.CreateGlobalVarBinding(F,
- When the
FunctionDeclaration f is evaluated, perform the following steps in place of theFunctionDeclaration Evaluation algorithm provided in15.2.6 :- Let genv be the
running execution context 's VariableEnvironment. - Let benv be the
running execution context 's LexicalEnvironment. - Let fobj be ! benv.GetBindingValue(F,
false ). - Perform ? genv.SetMutableBinding(F, fobj,
false ). - Return
NormalCompletion (empty ).
- Let genv be the
- NOTE: A var binding for F is only instantiated here if it is neither a VarDeclaredName nor the name of another
- If env.HasLexicalDeclaration(F) is
- Let F be
- Let declaredFunctionOrVarNames be a new empty
B.3.3.3 Changes to EvalDeclarationInstantiation
During
- If strict is
false , then- Let declaredFunctionOrVarNames be a new empty
List . - Append to declaredFunctionOrVarNames the elements of declaredFunctionNames.
- Append to declaredFunctionOrVarNames the elements of declaredVarNames.
- For each
FunctionDeclaration f that is directly contained in theStatementList of aBlock ,CaseClause , orDefaultClause Contained within body, do- Let F be
StringValue of theBindingIdentifier of f. - If replacing the
FunctionDeclaration f with aVariableStatement that has F as aBindingIdentifier would not produce any Early Errors for body, then- Let bindingExists be
false . - Let thisEnv be lexEnv.
Assert : The following loop will terminate.- Repeat, while thisEnv is not the same as varEnv,
- If thisEnv is not an
object Environment Record , then- If thisEnv.HasBinding(F) is
true , then- Let bindingExists be
true .
- Let bindingExists be
- If thisEnv.HasBinding(F) is
- Set thisEnv to thisEnv.[[OuterEnv]].
- If thisEnv is not an
- If bindingExists is
false and varEnv is aglobal Environment Record , then- If varEnv.HasLexicalDeclaration(F) is
false , then- Let fnDefinable be ? varEnv.CanDeclareGlobalVar(F).
- Else,
- Let fnDefinable be
false .
- Let fnDefinable be
- If varEnv.HasLexicalDeclaration(F) is
- Else,
- Let fnDefinable be
true .
- Let fnDefinable be
- If bindingExists is
false and fnDefinable istrue , then- If declaredFunctionOrVarNames does not contain F, then
- If varEnv is a
global Environment Record , then- Perform ? varEnv.CreateGlobalVarBinding(F,
true ).
- Perform ? varEnv.CreateGlobalVarBinding(F,
- Else,
- Let bindingExists be varEnv.HasBinding(F).
- If bindingExists is
false , then- Perform ! varEnv.CreateMutableBinding(F,
true ). - Perform ! varEnv.InitializeBinding(F,
undefined ).
- Perform ! varEnv.CreateMutableBinding(F,
- Append F to declaredFunctionOrVarNames.
- If varEnv is a
- When the
FunctionDeclaration f is evaluated, perform the following steps in place of theFunctionDeclaration Evaluation algorithm provided in15.2.6 :- Let genv be the
running execution context 's VariableEnvironment. - Let benv be the
running execution context 's LexicalEnvironment. - Let fobj be ! benv.GetBindingValue(F,
false ). - Perform ? genv.SetMutableBinding(F, fobj,
false ). - Return
NormalCompletion (empty ).
- Let genv be the
- If declaredFunctionOrVarNames does not contain F, then
- Let bindingExists be
- Let F be
- Let declaredFunctionOrVarNames be a new empty
B.3.3.4 Changes to Block Static Semantics: Early Errors
The rules for the following production in
-
It is a Syntax Error if the
LexicallyDeclaredNames ofStatementList contains any duplicate entries, unless the source code matching this production is notstrict mode code and the duplicate entries are only bound by FunctionDeclarations. -
It is a Syntax Error if any element of the
LexicallyDeclaredNames ofStatementList also occurs in theVarDeclaredNames ofStatementList .
B.3.3.5 Changes to switch
Statement Static Semantics: Early Errors
The rules for the following production in
-
It is a Syntax Error if the
LexicallyDeclaredNames ofCaseBlock contains any duplicate entries, unless the source code matching this production is notstrict mode code and the duplicate entries are only bound by FunctionDeclarations. -
It is a Syntax Error if any element of the
LexicallyDeclaredNames ofCaseBlock also occurs in theVarDeclaredNames ofCaseBlock .
B.3.3.6 Changes to BlockDeclarationInstantiation
During
- If env.HasBinding(dn) is
false , then- Perform ! env.CreateMutableBinding(dn,
false ).
- Perform ! env.CreateMutableBinding(dn,
During
- If the binding for fn in env is an uninitialized binding, then
- Perform env.InitializeBinding(fn, fo).
- Else,
Assert : d is aFunctionDeclaration .- Perform env.SetMutableBinding(fn, fo,
false ).
B.3.4 FunctionDeclarations in IfStatement Statement Clauses
The following augments the
This production only applies when parsing
B.3.5 VariableStatements in Catch Blocks
The content of subclause
-
It is a Syntax Error if
BoundNames ofCatchParameter contains any duplicate elements. -
It is a Syntax Error if any element of the
BoundNames ofCatchParameter also occurs in theLexicallyDeclaredNames ofBlock . -
It is a Syntax Error if any element of the
BoundNames ofCatchParameter also occurs in theVarDeclaredNames ofBlock unlessCatchParameter is .CatchParameter : BindingIdentifier
The var
declarations that bind a name that is also bound by the var
declarations will assign to the corresponding catch parameter rather than the var
binding.
This modified behaviour also applies to var
and function
declarations introduced by
Step
- If thisEnv is not the
Environment Record for aCatch clause, throw aSyntaxError exception.
Step
- If thisEnv is not the
Environment Record for aCatch clause, let bindingExists betrue .
B.3.6 Initializers in ForIn Statement Heads
The following augments the
This production only applies when parsing
The
- Return
ContainsDuplicateLabels ofStatement with argument labelSet.
The
- Return
ContainsUndefinedBreakTarget ofStatement with argument labelSet.
The
- Return
ContainsUndefinedContinueTarget ofStatement with arguments iterationSet and « ».
The
- Return
false .
The
- Let names be the
BoundNames ofBindingIdentifier . - Append to names the elements of the
VarDeclaredNames ofStatement . - Return names.
The
- Let declarations be a
List whose sole element isBindingIdentifier . - Append to declarations the elements of the
VarScopedDeclarations ofStatement . - Return declarations.
The
- Let bindingId be
StringValue ofBindingIdentifier . - Let lhs be ?
ResolveBinding (bindingId). - If
IsAnonymousFunctionDefinition (Initializer ) istrue , then- Let value be
NamedEvaluation ofInitializer with argument bindingId.
- Let value be
- Else,
- Let rhs be the result of evaluating
Initializer . - Let value be ?
GetValue (rhs).
- Let rhs be the result of evaluating
- Perform ?
PutValue (lhs, value). - Let keyResult be ?
ForIn/OfHeadEvaluation (« »,Expression ,enumerate ). - Return ?
ForIn/OfBodyEvaluation (BindingIdentifier ,Statement , keyResult,enumerate ,varBinding , labelSet).
B.3.7 The [[IsHTMLDDA]] Internal Slot
An [[IsHTMLDDA]] internal slot may exist on typeof
operator
Objects with an [[IsHTMLDDA]] internal slot are never created by this specification. However, the document.all
object in web browsers is a document.all
.
B.3.7.1 Changes to ToBoolean
The result column in
- If argument has an
[[IsHTMLDDA]] internal slot , returnfalse . - Return
true .
B.3.7.2 Changes to Abstract Equality Comparison
The following steps replace step
- If
Type (x) is Object and x has an[[IsHTMLDDA]] internal slot and y is eithernull orundefined , returntrue . - If x is either
null orundefined andType (y) is Object and y has an[[IsHTMLDDA]] internal slot , returntrue .
B.3.7.3 Changes to the typeof
Operator
The following table entry is inserted into
typeof
Type of val | Result |
---|---|
Object (has an |
|