Last Comment Bug 646807 - Remove extra RHS checking in CheckDestructuring
: Remove extra RHS checking in CheckDestructuring
Status: RESOLVED FIXED
[fixed-in-tracemonkey]
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Other Branch
: All All
: -- normal (vote)
: ---
Assigned To: Jason Orendorff [:jorendorff]
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-31 05:43 PDT by Jason Orendorff [:jorendorff]
Modified: 2011-04-26 15:38 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
v1 (9.04 KB, patch)
2011-03-31 05:56 PDT, Jason Orendorff [:jorendorff]
no flags Details | Diff | Review
v2 (10.89 KB, patch)
2011-03-31 07:18 PDT, Jason Orendorff [:jorendorff]
brendan: review+
Details | Diff | Review

Description Jason Orendorff [:jorendorff] 2011-03-31 05:43:50 PDT
In jsparse.cpp, CheckDestructuring raises an error if the destructuring shorthand {p1, p2} appears to the right of =.

That check is insufficient, since there are all sorts of other places where it might erroneously occur-- basically anywhere an expression is used as an rvalue. So js_EmitTree also checks, in the TOK_RC case.

The latter check seems to cover all the cases. CheckDestructuring doesn't need to check, and the code is shorter without it.
Comment 1 Jason Orendorff [:jorendorff] 2011-03-31 05:56:22 PDT
Created attachment 523289 [details] [diff] [review]
v1

Also updated to idiomatic C++.

-25 lines net.

(More where this came from, if I can ever get my def-use chains straight.)
Comment 2 Jason Orendorff [:jorendorff] 2011-03-31 07:18:13 PDT
Created attachment 523296 [details] [diff] [review]
v2

v1 left the declaration of fpvd even though it was unused. Deleting that leads to more simplifications, so it's a total of -40 lines.
Comment 3 Brendan Eich [:brendan] 2011-04-01 14:56:56 PDT
Comment on attachment 523296 [details] [diff] [review]
v2

Nice.

FYI, there is a Harmony proposal to support {p1, p2} for constructing an object with properties of those names, whose initial values come from the result of evaluating those lexical refs.

/be
Comment 4 Jason Orendorff [:jorendorff] 2011-04-19 20:45:02 PDT
http://hg.mozilla.org/tracemonkey/rev/87fc73e2264f
Comment 5 Chris Leary [:cdleary] (not checking bugmail) 2011-04-26 15:38:01 PDT
http://hg.mozilla.org/mozilla-central/rev/87fc73e2264f

Note You need to log in before you can comment on or make changes to this bug.