deopt rest parameter member expression optimisation on child arrow functions - fixes #1631

This commit is contained in:
Sebastian McKenzie
2015-05-28 10:22:12 -04:00
parent 4aec242979
commit 4901075960
3 changed files with 56 additions and 32 deletions

View File

@@ -9,6 +9,13 @@ var memberExpressionOptimisationVisitor = {
return this.skip();
}
var stop = () => {
state.canOptimise = false;
this.stop();
};
if (this.isArrowFunctionExpression()) return stop();
// skip over functions as whatever `arguments` we reference inside will refer
// to the wrong function
if (this.isFunctionDeclaration() || this.isFunctionExpression()) {
@@ -31,8 +38,7 @@ var memberExpressionOptimisationVisitor = {
}
}
state.canOptimise = false;
this.stop();
stop();
}
};
@@ -90,8 +96,7 @@ export function Func/*tion*/(node, parent, scope, file) {
// we only have shorthands and there's no other references
if (state.canOptimise && state.candidates.length) {
for (var i = 0; i < state.candidates.length; i++) {
var candidate = state.candidates[i];
for (var candidate of (state.candidates: Array)) {
candidate.replaceWith(argsId);
optimizeMemberExpression(candidate.parent, node.params.length);
}