diff --git a/lib/6to5/transformation/transformers/es6/tail-call.js b/lib/6to5/transformation/transformers/es6/tail-call.js index 5ad846c8cc..6d061bcf11 100644 --- a/lib/6to5/transformation/transformers/es6/tail-call.js +++ b/lib/6to5/transformation/transformers/es6/tail-call.js @@ -62,19 +62,16 @@ var functionChildrenVisitor = { // transform return argument into statement if // it contains tail recursion transformExpression(node.argument, scope, state); - return; } else if (t.isFunction(node)) { - return this.skip(); + // inner function's bodies are irrelevant + this.skip(); } else if (t.isTryStatement(parent)) { if (node === parent.block) { - return this.skip(); - } else if (node === parent.finalizer) { - return; - } else { - if (parent.finalizer) { - this.skip(); - } - return; + // `try`-blocks can't be optimized + this.skip(); + } else if (parent.finalizer && node !== parent.finalizer) { + // `catch` clause followed by `finally` can't be optimized + this.skip(); } } }