log spread element rest parameter as a candidate instead of replacing it in place - fixes #1796

This commit is contained in:
Sebastian McKenzie
2015-06-22 00:06:03 +01:00
parent ebaa06f4a2
commit 58cda35831
3 changed files with 19 additions and 2 deletions

View File

@@ -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;