deopt on spread elements when performing array destructuring unpack optimisation

This commit is contained in:
Sebastian McKenzie 2015-07-14 22:08:26 +01:00
parent 45e1eb343b
commit 7fb3158be7
3 changed files with 10 additions and 1 deletions

View File

@ -497,6 +497,9 @@ class DestructuringTransformer {
// deopt on holes
if (!elem) return false;
// deopt on spread elements
if (t.isSpreadElement(elem)) return false;
// deopt on member expressions
if (t.isMemberExpression(elem)) return false;
}

View File

@ -9,3 +9,4 @@ var [a, b] = [1, 2, 3];
var [[a, b]] = [[1, 2, 3]];
var [a, b] = [a, b];
[a[0], a[1]] = [a[1], a[0]];
var [a, b, c] = [...foo, bar];

View File

@ -25,4 +25,9 @@ var b = _ref3[1];
var _ref4 = [a[1], a[0]];
a[0] = _ref4[0];
a[1] = _ref4[1];
_ref4;
var _ref5 = [].concat(babelHelpers.toConsumableArray(foo), [bar]);
var a = _ref5[0];
var b = _ref5[1];
var c = _ref5[2];