Closed
Bug 1126361
Opened 11 years ago
Closed 11 years ago
Default value in destructuring cannot access to function argument.
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla38
People
(Reporter: arai, Unassigned)
References
Details
Attachments
(1 file)
|
1.54 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
Currently identifierName in default value in destructuring is not linked to definition node, and it's emitted as JSOP_GETNAME/JSOP_SETNAME, so it cannot access to function argument:
js> ((a, [b=a]) => b)(1, [])
typein:1:5 ReferenceError: a is not defined
It should be 1.
| Reporter | ||
Comment 1•11 years ago
|
||
| Reporter | ||
Comment 2•11 years ago
|
||
Set `pc->inDeclDestructuring` to false for RHS of assignment expression, so `noteNameUse` will be called in identifierName for default values.
Green on try run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=8c2ed4a0c781
With this fix, I can write remaining part of the patch in bug 1018628, yay :)
Attachment #8555409 -
Flags: review?(jorendorff)
Comment 3•11 years ago
|
||
Comment on attachment 8555409 [details] [diff] [review]
Lookup definition node for identifierName in default value in destructuring.
Review of attachment 8555409 [details] [diff] [review]:
-----------------------------------------------------------------
Thank you. Sorry for the slow review here!
::: js/src/frontend/Parser.cpp
@@ +6297,2 @@
> Node rhs = assignExpr();
> + pc->inDeclDestructuring = saved;
Good. I ran into the same thing in bug 1051760. I wish the front end wasn't so precarious. :-\
Attachment #8555409 -
Flags: review?(jorendorff) → review+
| Reporter | ||
Comment 4•11 years ago
|
||
Thank you for reviewing! :D
https://hg.mozilla.org/integration/mozilla-inbound/rev/6b0631da5300
| Reporter | ||
Comment 5•11 years ago
|
||
bug number in the commit message was wrong, sorry for my mistake!
https://hg.mozilla.org/mozilla-central/rev/6b0631da5300
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in
before you can comment on or make changes to this bug.
Description
•