Fix reused nodes - part 2 (#7149)

This commit is contained in:
Nicolò Ribaudo
2018-01-11 19:31:48 +01:00
parent 912bcc186d
commit 252ea5a966
20 changed files with 261 additions and 170 deletions

View File

@@ -289,8 +289,7 @@ export default function convertFunctionRest(path) {
const key = scope.generateUidIdentifier("key");
const len = scope.generateUidIdentifier("len");
let arrKey = key;
let arrLen = len;
let arrKey, arrLen;
if (node.params.length) {
// this method has additional params, so we need to subtract
// the index of the current argument position from the
@@ -308,6 +307,9 @@ export default function convertFunctionRest(path) {
t.binaryExpression("-", t.cloneNode(len), t.cloneNode(start)),
t.numericLiteral(0),
);
} else {
arrKey = t.identifier(key.name);
arrLen = t.identifier(len.name);
}
const loop = buildRest({