log spread element rest parameter as a candidate instead of replacing it in place - fixes #1796
This commit is contained in:
@@ -42,7 +42,8 @@ var memberExpressionOptimisationVisitor = {
|
||||
if (this.parentPath.isSpreadElement() && state.offset === 0) {
|
||||
var call = this.parentPath.parentPath;
|
||||
if (call.isCallExpression() && call.node.arguments.length === 1) {
|
||||
return state.argumentsNode;
|
||||
state.candidates.push(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,7 +125,9 @@ export var visitor = {
|
||||
if (state.candidates.length) {
|
||||
for (var candidate of (state.candidates: Array)) {
|
||||
candidate.replaceWith(argsId);
|
||||
optimiseMemberExpression(candidate.parent, state.offset);
|
||||
if (candidate.parentPath.isMemberExpression()) {
|
||||
optimiseMemberExpression(candidate.parent, state.offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -13,3 +13,8 @@ function foo(a, ...b) {
|
||||
function foo(...b) {
|
||||
foo(1, ...b);
|
||||
}
|
||||
|
||||
function foo(...args){
|
||||
args.pop()
|
||||
foo(...args);
|
||||
}
|
||||
|
||||
@@ -23,3 +23,12 @@ function foo() {
|
||||
|
||||
foo.apply(undefined, [1].concat(b));
|
||||
}
|
||||
|
||||
function foo() {
|
||||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
||||
args[_key3] = arguments[_key3];
|
||||
}
|
||||
|
||||
args.pop();
|
||||
foo.apply(undefined, args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user