Closed Bug 436731 Opened 18 years ago Closed 17 years ago

multiple destructuring forms in function param list

Categories

(Rhino Graveyard :: Core, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: steve.yegge, Assigned: norrisboyd)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 Build Identifier: Rhino 1.7 release 1 2008 03 06 You can define a function with multiple destructuring-forms as parameters, but calling the function results in a TypeError. Reproducible: Always Steps to Reproduce: SpiderMonkey: js> function foo([a, b], [c, d]) {print(a); print(b); print(c); print(d);} js> foo([1, 2], [3, 4]) 1 2 3 4 Rhino 1.7R1 (and also R2/trunk): js> function foo([a, b], [c, d]) {print(a); print(b); print(c); print(d);} js> foo([1, 2], [3, 4]) js: "<stdin>", line 2: uncaught JavaScript runtime exception: TypeError: Cannot read property "0" from undefined at <stdin>:2 (foo) at <stdin>:3 Actual Results: TypeError: cannot read property "0" from undefined Expected Results: See details field for SpiderMonkey behavior.
The problem is that destructuring assignment helpers are created while still parsing the parameters and before the function body has been parsed. Therefore they somehow trash the function scope. I guess it's because of their wrong parent scope, but I'm not completely sure. This patch fixes the problem.
Assignee: nobody → norrisboyd
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attached patch Updated patchSplinter Review
Update patch to refactored Parser code.
Attachment #337778 - Attachment is obsolete: true
Committed patch to CVS HEAD. Checking in src/org/mozilla/javascript/Parser.java; /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Parser.java,v <-- Parser.java new revision: 1.136; previous revision: 1.135 done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: