Skip to content

Commit

Permalink
Merge pull request tc39#50 from littledan/disallow-rest-destructuring
Browse files Browse the repository at this point in the history
Normative: Disallow binding patterns of arrays or objects
  • Loading branch information
sebmarkbage authored Jun 15, 2017
2 parents 00e338a + f152f9c commit ad13fdb
Showing 1 changed file with 27 additions and 40 deletions.
67 changes: 27 additions & 40 deletions Spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ <h1>Spread Properties</h1>

<h2>Syntax</h2>

<emu-production name="PropertyDefinition" params="Yield">
<emu-rhs><emu-nt params="?Yield">IdentifierReference</emu-nt></emu-rhs>
<emu-rhs><emu-nt params="?Yield">CoverInitializedName</emu-nt></emu-rhs>
<emu-rhs><emu-nt params="?Yield">PropertyName</emu-nt><emu-t>:</emu-t><emu-nt params="In, ?Yield">AssignmentExpression</emu-nt></emu-rhs>
<emu-rhs><emu-nt params="?Yield">MethodDefinition</emu-nt></emu-rhs>
<ins class="block">
<emu-rhs><emu-t>...</emu-t><emu-nt params="In, ?Yield">AssignmentExpression</emu-nt></emu-rhs>
</ins>
</emu-production>
<emu-grammar>
PropertyDefinition[Yield, Await] :
IdentifierReference[?Yield, ?Await]
CoverInitializedName[?Yield, ?Await]
PropertyName[?Yield, ?Await]
<ins class="block">`...` AssignmentExpression[In, ?Yield, ?Await]</ins>
</emu-grammar>

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

<h2>Syntax</h2>

<emu-production name="ObjectAssignmentPattern" params="Yield">
<emu-rhs><emu-t>{</emu-t><ins><emu-nt params="?Yield" optional>AssignmentRestProperty</emu-nt></ins><emu-t>}</emu-t></emu-rhs>
<emu-rhs><emu-t>{</emu-t><emu-nt params="?Yield">AssignmentPropertyList</emu-nt><emu-t>}</emu-t></emu-rhs>
<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>
</emu-production>
<emu-grammar>
ObjectAssignmentPattern[Yield, Await] :
`{` <ins>AssignmentRestProperty[?Yield, ?Await]?</ins> `}`
`{` AssignmentPropertyList[?Yield, ?Await] `}`
`{` AssignmentPropertyList[?Yield, ?Await] `,` <ins>AssignmentRestProperty[?Yield, ?Await]?</ins> `}`

<ins class="block">
<emu-production name="AssignmentRestProperty" params="Yield">
<emu-rhs><emu-t>...</emu-t><emu-nt params="?Yield">DestructuringAssignmentTarget</emu-nt></emu-rhs>
</emu-production>
</ins>
<ins class="block">
AssignmentRestProperty[Yield, Await] :
`...` DestructuringAssignmentTarget[Yield, Await]
</ins>

<emu-production name="ObjectBindingPattern" params="Yield">
<emu-rhs><emu-t>{</emu-t><ins><emu-nt params="?Yield" optional>BindingRestProperty</emu-nt></ins><emu-t>}</emu-t></emu-rhs>
<emu-rhs><emu-t>{</emu-t><emu-nt params="?Yield">BindingPropertyList</emu-nt><emu-t>}</emu-t></emu-rhs>
<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>
</emu-production>
ObjectBindingPattern[Yield, Await] :
`{` <ins>BindingRestProperty[?Yield, ?Await]?</ins> `}`
`{` BindingPropertyList[?Yield, ?Await] `}`
`{` BindingPropertyList[?Yield, ?Await] `,` <ins>BindingRestProperty[?Yield, ?Await]?</ins> `}`

<ins class="block">
<emu-production name="BindingRestProperty" params="Yield">
<emu-rhs><emu-t>...</emu-t><emu-nt params="?Yield">BindingIdentifier</emu-nt></emu-rhs>
<emu-rhs><emu-t>...</emu-t><emu-nt params="?Yield">BindingPattern</emu-nt></emu-rhs>
</emu-production>
</ins>
<ins class="block">
BindingRestProperty[Yield, Await] :
`...` BindingIdentifier[?Yield, ?Await]
</ins>
</emu-grammar>

<emu-clause id="Rest-RuntimeSemantics-DestructuringAssignmentEvaluation">
<h1>Runtime Semantics: DestructuringAssignmentEvaluation</h1>
Expand Down Expand Up @@ -177,7 +172,7 @@ <h1>Runtime Semantics: PropertyDestructuringAssignmentEvaluation</h1>
<h1>Runtime Semantics: RestDestructuringAssignmentEvaluation</h1>
<p>With parameters _value_ and _excludedNames_.</p>

<emu-grammar>AssignmentRestProperty[Yield] : `...` DestructuringAssignmentTarget</emu-grammar>
<emu-grammar>AssignmentRestProperty[Yield, Await] : `...` DestructuringAssignmentTarget</emu-grammar>
<emu-alg>
1. If |DestructuringAssignmentTarget| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
1. Let _lref_ be the result of evaluating |DestructuringAssignmentTarget|.
Expand All @@ -187,7 +182,7 @@ <h1>Runtime Semantics: RestDestructuringAssignmentEvaluation</h1>
1. ReturnIfAbrupt(_assignStatus_).
1. If |DestructuringAssignmentTarget| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
1. Return PutValue(_lref_, _restObj_).
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.
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|.
1. Return the result of performing DestructuringAssignmentEvaluation of _nestedAssignmentPattern_ with _restObj_ as the argument.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -284,14 +279,6 @@ <h1>Runtime Semantics: RestBindingInitialization</h1>
1. If _environment_ is *undefined*, return PutValue(_lhs_, _restObj_).
1. Return InitializeReferencedBinding(_lhs_, _restObj_).
</emu-alg>

<emu-grammar>BindingRestProperty : `...` BindingPattern</emu-grammar>
<emu-alg>
1. Let _restObj_ be ObjectCreate(%ObjectPrototype%).
1. Let _assignStatus_ be CopyDataProperties(_restObj_, _value_, _excludedNames_).
1. ReturnIfAbrupt(_assignStatus_).
1. Return the result of performing BindingInitialization of |BindingPattern| with _restObj_ and _environment_ as the arguments.
</emu-alg>
</emu-clause>
</ins>
</emu-clause>
Expand Down

0 comments on commit ad13fdb

Please sign in to comment.