Closed Bug 1107418 Opened 10 years ago Closed 8 years ago

Destructuring assignment of function arguments object is broken

Categories

(Core :: JavaScript Engine, defect)

34 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla46

People

(Reporter: torbasow, Unassigned)

References

Details

(Keywords: regression, reproducible, testcase)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Build ID: 20141113143407

Steps to reproduce:

(function test(a, b){let [x, y]=arguments;})(1,2);


Actual results:

undefined


Expected results:

TypeError: arguments['@@iterator'] is not a function
This works fine in Firefox 15, 21, 24, 25, 30, 32 and 33, although arguments was not iterable at Fx24 yet (bug 1067049). Try (function test(a, b){for(x of arguments);})(1,2). This works in Fx15 and doesn’t work in Fx24 and later.
2014-12-07-03-02-05-mozilla-central-firefox-37.0a1.ru.linux-x86_64

(function test(a, b){let [x, y]=arguments;})(1,2);
Exception: arguments[Symbol.iterator] is not a function

(function test(a, b){for(x of arguments);})(1,2)
Exception: arguments[Symbol.iterator] is not a function
QA Whiteboard: [bugday-20141208]
Jan, was this a deliberate change? I don't know enough about the spec here to know if this is supposed to work...
Component: Untriaged → JavaScript Engine
Flags: needinfo?(jdemooij)
Product: Firefox → Core
Summary: Restructuring assignment of arguments was broken → Destructuring assignment of function arguments object is broken
Problem is that `arguments` object don't have a Symbol.iterator property. In the spec I don't see @@iterator defined for arguments objects but maybe I'm missing something...
Flags: needinfo?(jdemooij) → needinfo?(jorendorff)
Per spec, "let [x, y] = foo" iterates foo twice and assigns the results to x and y.

Also per spec afaict arguments objects should be iterable, but we haven't fixed bug 1067049 yet.  Presumably we should just fix that.
Depends on: 1067049
Ah thanks Boris. Not sure how I missed that when I searched for @@iterator...
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jorendorff)
Yup, this works now that bug 1067049 is fixed.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
You need to log in before you can comment on or make changes to this bug.