Default object arguments are not defined as lexical dependencies.

RESOLVED FIXED in Firefox 50

Status

()

Core
JavaScript Engine
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: Stefan Sechelmann, Assigned: mrrrgn)

Tracking

Trunk
mozilla50
Points:
---

Firefox Tracking Flags

(firefox50 fixed)

Details

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36

Steps to reproduce:

Define the following function:
f = function(a){ (function({aa = a}){ console.log('result: ' + aa); })({}); }
invoke it
f(42)


Actual results:

ReferenceError: a is not defined


Expected results:

console log: result: 42

Updated

2 years ago
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
maybe similar issue to bug 1126361
Blocks: 932080
Status: UNCONFIRMED → NEW
Ever confirmed: true
See Also: → bug 1126361
(Assignee)

Comment 2

2 years ago
The right hand side of the destructuring assignment isn't being added to pc->lexdeps. Adding it will ensure that it is defined in the inner function's scope via Parser::leaveFunction

Coming up with a patch for this in a jiffy.
(Assignee)

Updated

2 years ago
Assignee: nobody → winter2718
(Assignee)

Updated

2 years ago
Summary: Function parameter gets optimized away when used as the default of a named parameter only → Default object arguments are not defined as lexical dependencies.
(Assignee)

Updated

2 years ago
Attachment #8760939 - Flags: review?(jorendorff)
Attachment #8760939 - Flags: review?(jorendorff) → review+

Comment 4

2 years ago
Pushed by mphillips@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/095c359e97ad
Default destructuring arguments should show up as lexical dependencies; r=jorendorff

Comment 5

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/095c359e97ad
Status: NEW → RESOLVED
Last Resolved: 2 years ago
status-firefox50: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla50

Updated

2 years ago
Duplicate of this bug: 1300760
You need to log in before you can comment on or make changes to this bug.