From 1c304965e7f5e4049ed60ea72469061ab59edccf Mon Sep 17 00:00:00 2001 From: Jesse McCarthy Date: Mon, 22 Feb 2016 18:13:18 -0500 Subject: [PATCH] Add rest loop position optimization fixture. (Failing.) With destructuring assignment to an element. This makes the function ineligible for `arguments` optimization, while remaining eligible for loop position optimization. --- .../actual.js | 8 +++++++- .../expected.js | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/babel-plugin-transform-es2015-parameters/test/fixtures/parameters/rest-deepest-common-ancestor-earliest-child/actual.js b/packages/babel-plugin-transform-es2015-parameters/test/fixtures/parameters/rest-deepest-common-ancestor-earliest-child/actual.js index 3f3606cb0a..646ce0290e 100644 --- a/packages/babel-plugin-transform-es2015-parameters/test/fixtures/parameters/rest-deepest-common-ancestor-earliest-child/actual.js +++ b/packages/babel-plugin-transform-es2015-parameters/test/fixtures/parameters/rest-deepest-common-ancestor-earliest-child/actual.js @@ -1,4 +1,4 @@ -// single referenes +// single reference function r(...rest){ if (noNeedToWork) return 0; return rest; @@ -66,3 +66,9 @@ function runQueue(queue, ...args) { } } } + +function r(...rest){ + if (noNeedToWork) return 0; + [rest[0]] = x; + return rest; +} diff --git a/packages/babel-plugin-transform-es2015-parameters/test/fixtures/parameters/rest-deepest-common-ancestor-earliest-child/expected.js b/packages/babel-plugin-transform-es2015-parameters/test/fixtures/parameters/rest-deepest-common-ancestor-earliest-child/expected.js index 320886f014..3876f086d8 100644 --- a/packages/babel-plugin-transform-es2015-parameters/test/fixtures/parameters/rest-deepest-common-ancestor-earliest-child/expected.js +++ b/packages/babel-plugin-transform-es2015-parameters/test/fixtures/parameters/rest-deepest-common-ancestor-earliest-child/expected.js @@ -1,4 +1,4 @@ -// single referenes +// single reference function r() { if (noNeedToWork) return 0; @@ -99,3 +99,19 @@ function runQueue(queue) { } } } + +function r() { + if (noNeedToWork) return 0; + + for (var _len9 = arguments.length, rest = Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { + rest[_key9] = arguments[_key9]; + } + + var _x = x; + + var _x2 = babelHelpers.slicedToArray(_x, 1); + + rest[0] = _x2[0]; + + return rest; +}