Skip to content

Commit 81dd5ed

Browse files
committed
Normative: Disallow nested destructuring assignment with rest properties
Follow-up for tc39#43
1 parent ad13fdb commit 81dd5ed

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Spec.html

+12-7
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ <h1>Runtime Semantics: DestructuringAssignmentEvaluation</h1>
125125
</emu-clause>
126126

127127
<ins class="block">
128+
<emu-clause id="nested-rest-prohibition">
129+
<h1>Static Semantics: Early Errors</h1>
130+
<emu-grammar>
131+
AssignmentRestProperty[Yield, Await] :
132+
`...` DestructuringAssignmentTarget[Yield, Await]
133+
</emu-grammar>
134+
<ul><li>It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.</li></ul>
135+
</emu-clause>
136+
128137
<emu-clause id="Rest-RuntimeSemantics-PropertyDestructuringAssignmentEvaluation">
129138
<h1>Runtime Semantics: PropertyDestructuringAssignmentEvaluation</h1>
130139
<p>With parameters _value_.</p>
@@ -174,16 +183,12 @@ <h1>Runtime Semantics: RestDestructuringAssignmentEvaluation</h1>
174183

175184
<emu-grammar>AssignmentRestProperty[Yield, Await] : `...` DestructuringAssignmentTarget</emu-grammar>
176185
<emu-alg>
177-
1. If |DestructuringAssignmentTarget| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
178-
1. Let _lref_ be the result of evaluating |DestructuringAssignmentTarget|.
179-
1. ReturnIfAbrupt(_lref_).
186+
1. Let _lref_ be the result of evaluating |DestructuringAssignmentTarget|.
187+
1. ReturnIfAbrupt(_lref_).
180188
1. Let _restObj_ be ObjectCreate(%ObjectPrototype%).
181189
1. Let _assignStatus_ be CopyDataProperties(_restObj_, _value_, _excludedNames_).
182190
1. ReturnIfAbrupt(_assignStatus_).
183-
1. If |DestructuringAssignmentTarget| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
184-
1. Return PutValue(_lref_, _restObj_).
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|.
186-
1. Return the result of performing DestructuringAssignmentEvaluation of _nestedAssignmentPattern_ with _restObj_ as the argument.
191+
1. Return PutValue(_lref_, _restObj_).
187192
</emu-alg>
188193
</emu-clause>
189194
</ins>

0 commit comments

Comments
 (0)