Fix destructuring evaluation with call expressions (#4552)

* Fix destructuring evaluation with call expressions

Do not optimize destructions with callExpressions, as the call
might change the value of a variable that we are assigning to.

Fixes #4054

* Also deopt on member expressions

members expressions might be getters who have side effects
This commit is contained in:
Daniel Tschinder
2016-09-25 01:08:53 +02:00
committed by Henry Zhu
parent a83262026f
commit c2d2702cf9
3 changed files with 18 additions and 0 deletions

View File

@@ -221,6 +221,12 @@ export default function ({ types: t }) {
for (let elem of (arr.elements: Array)) {
// deopt on spread elements
if (t.isSpreadElement(elem)) return false;
// deopt call expressions as they might change values of LHS variables
if (t.isCallExpression(elem)) return false;
// deopt on member expressions as they may be getter/setters and have side-effects
if (t.isMemberExpression(elem)) return false;
}
// deopt on reference to left side identifiers