Skip to content

Commit ad13fdb

Browse files
authored
Merge pull request tc39#50 from littledan/disallow-rest-destructuring
Normative: Disallow binding patterns of arrays or objects
2 parents 00e338a + f152f9c commit ad13fdb

File tree

1 file changed

+27
-40
lines changed

1 file changed

+27
-40
lines changed

Spec.html

+27-40
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ <h1>Spread Properties</h1>
3333

3434
<h2>Syntax</h2>
3535

36-
<emu-production name="PropertyDefinition" params="Yield">
37-
<emu-rhs><emu-nt params="?Yield">IdentifierReference</emu-nt></emu-rhs>
38-
<emu-rhs><emu-nt params="?Yield">CoverInitializedName</emu-nt></emu-rhs>
39-
<emu-rhs><emu-nt params="?Yield">PropertyName</emu-nt><emu-t>:</emu-t><emu-nt params="In, ?Yield">AssignmentExpression</emu-nt></emu-rhs>
40-
<emu-rhs><emu-nt params="?Yield">MethodDefinition</emu-nt></emu-rhs>
41-
<ins class="block">
42-
<emu-rhs><emu-t>...</emu-t><emu-nt params="In, ?Yield">AssignmentExpression</emu-nt></emu-rhs>
43-
</ins>
44-
</emu-production>
36+
<emu-grammar>
37+
PropertyDefinition[Yield, Await] :
38+
IdentifierReference[?Yield, ?Await]
39+
CoverInitializedName[?Yield, ?Await]
40+
PropertyName[?Yield, ?Await]
41+
<ins class="block">`...` AssignmentExpression[In, ?Yield, ?Await]</ins>
42+
</emu-grammar>
4543

4644
<emu-clause id="Spread-RuntimeSemantics-PropertyDefinitionEvaluation">
4745
<h1>Runtime Semantics: PropertyDefinitionEvaluation</h1>
@@ -66,30 +64,27 @@ <h1>Rest Properties</h1>
6664

6765
<h2>Syntax</h2>
6866

69-
<emu-production name="ObjectAssignmentPattern" params="Yield">
70-
<emu-rhs><emu-t>{</emu-t><ins><emu-nt params="?Yield" optional>AssignmentRestProperty</emu-nt></ins><emu-t>}</emu-t></emu-rhs>
71-
<emu-rhs><emu-t>{</emu-t><emu-nt params="?Yield">AssignmentPropertyList</emu-nt><emu-t>}</emu-t></emu-rhs>
72-
<emu-rhs><emu-t>{</emu-t><emu-nt params="?Yield">AssignmentPropertyList</emu-nt><emu-t>,</emu-t><ins><emu-nt params="?Yield" optional>AssignmentRestProperty</emu-nt></ins><emu-t>}</emu-t></emu-rhs>
73-
</emu-production>
67+
<emu-grammar>
68+
ObjectAssignmentPattern[Yield, Await] :
69+
`{` <ins>AssignmentRestProperty[?Yield, ?Await]?</ins> `}`
70+
`{` AssignmentPropertyList[?Yield, ?Await] `}`
71+
`{` AssignmentPropertyList[?Yield, ?Await] `,` <ins>AssignmentRestProperty[?Yield, ?Await]?</ins> `}`
7472

75-
<ins class="block">
76-
<emu-production name="AssignmentRestProperty" params="Yield">
77-
<emu-rhs><emu-t>...</emu-t><emu-nt params="?Yield">DestructuringAssignmentTarget</emu-nt></emu-rhs>
78-
</emu-production>
79-
</ins>
73+
<ins class="block">
74+
AssignmentRestProperty[Yield, Await] :
75+
`...` DestructuringAssignmentTarget[Yield, Await]
76+
</ins>
8077

81-
<emu-production name="ObjectBindingPattern" params="Yield">
82-
<emu-rhs><emu-t>{</emu-t><ins><emu-nt params="?Yield" optional>BindingRestProperty</emu-nt></ins><emu-t>}</emu-t></emu-rhs>
83-
<emu-rhs><emu-t>{</emu-t><emu-nt params="?Yield">BindingPropertyList</emu-nt><emu-t>}</emu-t></emu-rhs>
84-
<emu-rhs><emu-t>{</emu-t><emu-nt params="?Yield">BindingPropertyList</emu-nt><emu-t>,</emu-t><ins><emu-nt params="?Yield" optional>BindingRestProperty</emu-nt></ins><emu-t>}</emu-t></emu-rhs>
85-
</emu-production>
78+
ObjectBindingPattern[Yield, Await] :
79+
`{` <ins>BindingRestProperty[?Yield, ?Await]?</ins> `}`
80+
`{` BindingPropertyList[?Yield, ?Await] `}`
81+
`{` BindingPropertyList[?Yield, ?Await] `,` <ins>BindingRestProperty[?Yield, ?Await]?</ins> `}`
8682

87-
<ins class="block">
88-
<emu-production name="BindingRestProperty" params="Yield">
89-
<emu-rhs><emu-t>...</emu-t><emu-nt params="?Yield">BindingIdentifier</emu-nt></emu-rhs>
90-
<emu-rhs><emu-t>...</emu-t><emu-nt params="?Yield">BindingPattern</emu-nt></emu-rhs>
91-
</emu-production>
92-
</ins>
83+
<ins class="block">
84+
BindingRestProperty[Yield, Await] :
85+
`...` BindingIdentifier[?Yield, ?Await]
86+
</ins>
87+
</emu-grammar>
9388

9489
<emu-clause id="Rest-RuntimeSemantics-DestructuringAssignmentEvaluation">
9590
<h1>Runtime Semantics: DestructuringAssignmentEvaluation</h1>
@@ -177,7 +172,7 @@ <h1>Runtime Semantics: PropertyDestructuringAssignmentEvaluation</h1>
177172
<h1>Runtime Semantics: RestDestructuringAssignmentEvaluation</h1>
178173
<p>With parameters _value_ and _excludedNames_.</p>
179174

180-
<emu-grammar>AssignmentRestProperty[Yield] : `...` DestructuringAssignmentTarget</emu-grammar>
175+
<emu-grammar>AssignmentRestProperty[Yield, Await] : `...` DestructuringAssignmentTarget</emu-grammar>
181176
<emu-alg>
182177
1. If |DestructuringAssignmentTarget| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
183178
1. Let _lref_ be the result of evaluating |DestructuringAssignmentTarget|.
@@ -187,7 +182,7 @@ <h1>Runtime Semantics: RestDestructuringAssignmentEvaluation</h1>
187182
1. ReturnIfAbrupt(_assignStatus_).
188183
1. If |DestructuringAssignmentTarget| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
189184
1. Return PutValue(_lref_, _restObj_).
190-
1. Let _nestedAssignmentPattern_ be the parse of the source text corresponding to |DestructuringAssignmentTarget| using either |AssignmentPattern| or |AssignmentPattern[Yield]| as the goal symbol depending upon whether this |AssignmentRestProperty| has the <sub>[Yield]</sub> parameter.
185+
1. Let _nestedAssignmentPattern_ be the parse of the source text corresponding to |DestructuringAssignmentTarget| using either |AssignmentPattern[?Yield, ?Await]| as the goal symbol, adopting the parameter values from |AssignmentRestProperty|.
191186
1. Return the result of performing DestructuringAssignmentEvaluation of _nestedAssignmentPattern_ with _restObj_ as the argument.
192187
</emu-alg>
193188
</emu-clause>
@@ -284,14 +279,6 @@ <h1>Runtime Semantics: RestBindingInitialization</h1>
284279
1. If _environment_ is *undefined*, return PutValue(_lhs_, _restObj_).
285280
1. Return InitializeReferencedBinding(_lhs_, _restObj_).
286281
</emu-alg>
287-
288-
<emu-grammar>BindingRestProperty : `...` BindingPattern</emu-grammar>
289-
<emu-alg>
290-
1. Let _restObj_ be ObjectCreate(%ObjectPrototype%).
291-
1. Let _assignStatus_ be CopyDataProperties(_restObj_, _value_, _excludedNames_).
292-
1. ReturnIfAbrupt(_assignStatus_).
293-
1. Return the result of performing BindingInitialization of |BindingPattern| with _restObj_ and _environment_ as the arguments.
294-
</emu-alg>
295282
</emu-clause>
296283
</ins>
297284
</emu-clause>

0 commit comments

Comments
 (0)