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)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: arai, Unassigned)

References

Details

Attachments

(1 file)

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.
Blocks: 932080
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 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+
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
See Also: → 1255167
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: