Closed
Bug 417568
Opened 16 years ago
Closed 5 years ago
Incorrect destructuring assignment
Categories
(Rhino Graveyard :: Compiler, defect)
Tracking
(Not tracked)
RESOLVED
INACTIVE
People
(Reporter: norrisboyd, Assigned: norrisboyd)
Details
Attachments
(2 files)
198 bytes,
text/plain
|
Details | |
1.99 KB,
patch
|
Details | Diff | Splinter Review |
Steve Yegge wrote: js> [[x, y].toSource() for ([x, y] in {foo: 'bar', hi: 'there'})] ["f", "o"],["h", "i"] Seems like it ought to print: ["foo", "bar"], ["hi", "there"] doesn't it?
Comment 1•16 years ago
|
||
It's also bugged for destructuring over an array: js> [[x, y].toSource() for ([x, y] in [[1, 2], [3, 4], [5, 6]])] ["0", , ],["1", , ],["2", , ]
Assignee | ||
Updated•16 years ago
|
Assignee: nobody → norrisboyd
Assignee | ||
Comment 2•16 years ago
|
||
Doctest for failure
Comment 3•16 years ago
|
||
I changed array comprehension parsing to handle destructuring assignments in the same way ordinary for loops do. I guess I was lucky :-)
Comment 4•16 years ago
|
||
A few observations: With JavaScript 1.8, spidermonkey behaviour changes back to destructuring the key strings: js> version(170) 180 js> [[x, y].toSource() for ([x, y] in {foo: 'bar', hi: 'there'})] ["foo", "bar"],["hi", "there"] js> version(180) 170 js> [[x, y].toSource() for ([x, y] in {foo: 'bar', hi: 'there'})] ["f", "o"],["h", "i"] js> Also see the last paragraph in the "what's new in js 1.8" page: https://developer.mozilla.org/en/New_in_JavaScript_1.8#Changes_in_destructuring_for..in I also noticed that my patch breaks test case js1_7/regress/regress-428706.js, complaining about more than 2 elements in the destructuring left hand side, which spidermonkey seems to accept if the third element is actually empty. Spidermonkey JS 1.8 seems to accept indefinite destructuring array elements, but only in ordinary loops, not array comprehension. IMO the question is whether array comprehension should follow the same rules as for loops. If the answer is yes, I think my patch is correct after all.
Comment 5•5 years ago
|
||
Closing. Bug management is now done here:
https://github.com/mozilla/rhino
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INACTIVE
You need to log in
before you can comment on or make changes to this bug.
Description
•