Last Comment Bug 646807 - Remove extra RHS checking in CheckDestructuring
: Remove extra RHS checking in CheckDestructuring
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Other Branch
: All All
-- normal (vote)
: ---
Assigned To: Jason Orendorff [:jorendorff]
: Jason Orendorff [:jorendorff]
Depends on:
  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:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

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

Description User image 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 User image Jason Orendorff [:jorendorff] 2011-03-31 05:56:22 PDT
Created attachment 523289 [details] [diff] [review]

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 User image Jason Orendorff [:jorendorff] 2011-03-31 07:18:13 PDT
Created attachment 523296 [details] [diff] [review]

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 User image Brendan Eich [:brendan] 2011-04-01 14:56:56 PDT
Comment on attachment 523296 [details] [diff] [review]


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.

Comment 4 User image Jason Orendorff [:jorendorff] 2011-04-19 20:45:02 PDT
Comment 5 User image Chris Leary [:cdleary] (not checking bugmail) 2011-04-26 15:38:01 PDT

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