diff --git a/lib/6to5/transformation/transformers/es6/tail-call.js b/lib/6to5/transformation/transformers/es6/tail-call.js index 3f8888f84e..37581f7a96 100644 --- a/lib/6to5/transformation/transformers/es6/tail-call.js +++ b/lib/6to5/transformation/transformers/es6/tail-call.js @@ -132,6 +132,8 @@ TailCallTransformer.prototype.run = function () { }; TailCallTransformer.prototype.subTransform = function (node) { + if (!node) return; + var handler = this["subTransform" + node.type]; if (handler) return handler.call(this, node); }; @@ -324,8 +326,10 @@ var secondPass = { var thirdPass = { enter: function (node, parent, scope, state) { if (!t.isExpressionStatement(node)) return; + var expr = node.expression; if (!t.isAssignmentExpression(expr)) return; + if (!state.needsThis && expr.left === state.getThisId()) { this.remove(); } else if (!state.needsArguments && expr.left === state.getArgumentsId() && t.isArrayExpression(expr.right)) {