From b482c988790b7dd8e5bc6bbe53d9890d34a4ba46 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 20 Jun 2016 11:16:22 -0700 Subject: [PATCH] Normative: Allow initializers in ForInStatement heads --- spec.html | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/spec.html b/spec.html index b14842967f..18ec751342 100644 --- a/spec.html +++ b/spec.html @@ -15388,6 +15388,9 @@

Syntax

BindingIdentifier[?Yield] BindingPattern[?Yield] + +

This section is extended by Annex .

+
@@ -15852,6 +15855,9 @@

Static Semantics: ContainsDuplicateLabels

1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. + +

This section is extended by Annex .

+
@@ -15871,6 +15877,9 @@

Static Semantics: ContainsUndefinedBreakTarget

1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. + +

This section is extended by Annex .

+
@@ -15890,6 +15899,9 @@

Static Semantics: ContainsUndefinedContinueTarget

1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». + +

This section is extended by Annex .

+
@@ -15908,6 +15920,9 @@

Static Semantics: IsDestructuring

1. Return *true*. + +

This section is extended by Annex .

+
@@ -15942,6 +15957,9 @@

Static Semantics: VarDeclaredNames

1. Return the VarDeclaredNames of |Statement|. + +

This section is extended by Annex .

+
@@ -15976,6 +15994,9 @@

Static Semantics: VarScopedDeclarations

1. Return the VarScopedDeclarations of |Statement|. + +

This section is extended by Annex .

+
@@ -16043,6 +16064,9 @@

Runtime Semantics: LabelledEvaluation

1. Let _keyResult_ be the result of performing ? ForIn/OfHeadEvaluation(BoundNames of |ForDeclaration|, |AssignmentExpression|, ~iterate~). 1. Return ? ForIn/OfBodyEvaluation(|ForDeclaration|, |Statement|, _keyResult_, ~lexicalBinding~, _labelSet_). + +

This section is extended by Annex .

+
@@ -36616,6 +36640,69 @@

VariableStatements in Catch Blocks

1. If _thisEnvRec_ is not the Environment Record for a |Catch| clause, let _bindingExists_ be *true*. + + + +

Initializers in ForIn Statement Heads

+

The following augments the |IterationStatement| production in :

+ + IterationStatement[Yield, Return]: + `for` `(` `var` BindingIdentifier[?Yield] Initializer[~In, ?Yield] `in` Expression[+In, ?Yield] `)` Statement[?Yield, ?Return] + +

This production only applies when parsing non-strict code.

+

The static semantics of ContainsDuplicateLabels in are augmented with the following:

+ IterationStatement : `for` `(` `var` BindingIdentifier Initializer `in` Expression `)` Statement + + 1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. + +

The static semantics of ContainsUndefinedBreakTarget in are augmented with the following:

+ IterationStatement : `for` `(` `var` BindingIdentifier Initializer `in` Expression `)` Statement + + 1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. + +

The static semantics of ContainsUndefinedContinueTarget in are augmented with the following:

+ IterationStatement : `for` `(` `var` BindingIdentifier Initializer `in` Expression `)` Statement + + 1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». + +

The static semantics of IsDestructuring in are augmented with the following:

+ + BindingIdentifier : + Identifier + `yield` + + + 1. Return *false*. + +

The static semantics of VarDeclaredNames in are augmented with the following:

+ IterationStatement : `for` `(` `var` BindingIdentifier Initializer `in` Expression `)` Statement + + 1. Let _names_ be the BoundNames of |BindingIdentifier|. + 1. Append to _names_ the elements of the VarDeclaredNames of |Statement|. + 1. Return _names_. + +

The static semantics of VarScopedDeclarations in are augmented with the following:

+ IterationStatement : `for` `(` `var` BindingIdentifier Initializer `in` Expression `)` Statement + + 1. Let _declarations_ be a List containing |BindingIdentifier|. + 1. Append to _declarations_ the elements of the VarScopedDeclarations of |Statement|. + 1. Return _declarations_. + +

The runtime semantics of LabelledEvaluation in are augmented with the following:

+ IterationStatement : `for` `(` `var` BindingIdentifier Initializer `in` Expression `)` Statement + + 1. Let _bindingId_ be StringValue of |BindingIdentifier|. + 1. Let _lhs_ be ? ResolveBinding(_bindingId_). + 1. Let _rhs_ be the result of evaluating |Initializer|. + 1. Let _value_ be ? GetValue(_rhs_). + 1. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then + 1. Let _hasNameProperty_ be ? HasOwnProperty(_value_, `"name"`). + 1. If _hasNameProperty_ is *false*, perform SetFunctionName(_value_, _bindingId_). + 1. Perform ? PutValue(_lhs_, _value_). + 1. Let _keyResult_ be ? ForIn/OfHeadEvaluation(« », |Expression|, ~enumerate~). + 1. Return ? ForIn/OfBodyEvaluation(|BindingIdentifier|, |Statement|, _keyResult_, ~varBinding~, _labelSet_). + +
@@ -36706,7 +36793,7 @@

Additions and Changes That Introduce Incompatibilities with Prior Editions: In ECMAScript 2015, the normal completion value of an |IfStatement| is never the value ~empty~. If no |Statement| part is evaluated or if the evaluated |Statement| part produces a normal completion whose value is ~empty~, the completion value of the |IfStatement| is *undefined*.

: In ECMAScript 2015, if the `(` token of a for statement is immediately followed by the token sequence `let [` then the `let` is treated as the start of a |LexicalDeclaration|. In previous editions such a token sequence would be the start of an |Expression|.

: In ECMAScript 2015, if the ( token of a for-in statement is immediately followed by the token sequence `let [` then the `let` is treated as the start of a |ForDeclaration|. In previous editions such a token sequence would be the start of an |LeftHandSideExpression|.

-

: Prior to ECMAScript 2015, an initialization expression could appear as part of the |VariableDeclaration| that precedes the `in` keyword. The value of that expression was always discarded. In ECMAScript 2015, the _ForBinding_ in that same position does not allow the occurrence of such an initializer.

+

: Prior to ECMAScript 2015, an initialization expression could appear as part of the |VariableDeclaration| that precedes the `in` keyword. In ECMAScript 2015, the |ForBinding| in that same position does not allow the occurrence of such an initializer. In ECMAScript 2017, such an initializer is permitted only in non-strict code.

: In ECMAScript 2015, the completion value of an |IterationStatement| is never the value ~empty~. If the |Statement| part of an |IterationStatement| is not evaluated or if the final evaluation of the |Statement| part produces a completion whose value is ~empty~, the completion value of the |IterationStatement| is *undefined*.

: In ECMAScript 2015, the normal completion value of a |WithStatement| is never the value ~empty~. If evaluation of the |Statement| part of a |WithStatement| produces a normal completion whose value is ~empty~, the completion value of the |WithStatement| is *undefined*.

: In ECMAScript 2015, the completion value of a |SwitchStatement| is never the value ~empty~. If the |CaseBlock| part of a |SwitchStatement| produces a completion whose value is ~empty~, the completion value of the |SwitchStatement| is *undefined*.