Closed
Bug 1111386
Opened 9 years ago
Closed 8 years ago
Support nested rest in destructuring assignment
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla47
Tracking | Status | |
---|---|---|
firefox47 | --- | fixed |
People
(Reporter: Swatinem, Assigned: Swatinem)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
While it was not supported so far, with the latest draft 29, nested rest in destructuring assignment, such as `[first, ...[a[2], last]] = a;` is now possible. Lets implement it…
Comment 1•9 years ago
|
||
I almost filed a duplicate for this. Here's some more information, in case it helps Input: $ js -e "[...[x, y, z]] = [1, 2, 3]; print(z);" Expected: "3" Actual: -e:1:4 SyntaxError: invalid destructuring target: -e:1:4 [...[x, y, z]] = [1, 2, 3]; print(z); -e:1:4 ....^ From ES6 12.14.5.3: > Runtime Semantics: IteratorDestructuringAssignmentEvaluation > > AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget > > 5. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an > ArrayLiteral, then > a. Return PutValue(lref, A). > 6. 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 > AssignmentElement has the Yield parameter. > a. Return the result of performing DestructuringAssignmentEvaluation of nestedAssignmentPattern with A as the argument. Source: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-iteratordestructuringassignmentevaluation Build details: commit 07bb578e6a93d11a3e1365e2b0d9296a755543ee Date: Fri Apr 17 13:52:50 2015 -0700
Assignee | ||
Comment 2•8 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/29065/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/29065/
Attachment #8702007 -
Flags: review?(jorendorff)
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → arpad.borsos
Status: NEW → ASSIGNED
Comment 3•8 years ago
|
||
Comment on attachment 8702007 [details] MozReview Request: Bug 1111386 - Support nested rest in destructuring assignment; r?jorendorff https://reviewboard.mozilla.org/r/29065/#review29033 Sorry for the belated review here. Looks good. I'd like just a few more tests here. - `"use strict"; [...{0: "".x}] = gen();` should exhaust the whole generator before throwing a TypeError. - If an error is thrown on the right-hand side of a `let [...[...x]] = rhs();` in the global scope, the binding `x` is left uninitialized, and trying to read it after that is a TDZ ReferenceError. (I think this can be observed using evaluate() in a try/catch block. If not, never mind.) ::: js/src/jit-test/tests/basic/destructuring-iterator.js:63 (Diff revision 1) > +// second rest pattern. Great test.
Attachment #8702007 -
Flags: review?(jorendorff) → review+
Assignee | ||
Comment 4•8 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/664f46e3d8845b5e9e5b78608ddd867ba072237c Bug 1111386 - Support nested rest in destructuring assignment; r=jorendorff
Comment 5•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/664f46e3d884
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox47:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
You need to log in
before you can comment on or make changes to this bug.
Description
•