diff --git a/lib/6to5/transformation/transformers/es6/tail-call.js b/lib/6to5/transformation/transformers/es6/tail-call.js index b9af8e209a..c54259135c 100644 --- a/lib/6to5/transformation/transformers/es6/tail-call.js +++ b/lib/6to5/transformation/transformers/es6/tail-call.js @@ -210,6 +210,4 @@ exports.FunctionExpression = function (node, parent, scope) { ]), shouldContinueId), t.returnStatement(resultId) ]); - - node.params = []; }; diff --git a/lib/6to5/transformation/transformers/index.js b/lib/6to5/transformation/transformers/index.js index ab5aff2ee9..ffd23e19bb 100644 --- a/lib/6to5/transformation/transformers/index.js +++ b/lib/6to5/transformation/transformers/index.js @@ -52,13 +52,13 @@ module.exports = { // needs to be after `es6.blockScoping` due to needing `letReferences` set on blocks "es6.blockScopingTDZ": require("./es6/block-scoping-tdz"), - "es6.tailCall": require("./es6/tail-call"), - "es6.parameters.default": require("./es6/parameters.default"), "es6.parameters.rest": require("./es6/parameters.rest"), "es6.destructuring": require("./es6/destructuring"), + "es6.tailCall": require("./es6/tail-call"), + regenerator: require("./other/regenerator"), // needs to be after `regenerator` due to needing `regeneratorRuntime` references diff --git a/test/fixtures/transformation/es6-tail-call/call-apply/expected.js b/test/fixtures/transformation/es6-tail-call/call-apply/expected.js index 806974a174..56732fe861 100644 --- a/test/fixtures/transformation/es6-tail-call/call-apply/expected.js +++ b/test/fixtures/transformation/es6-tail-call/call-apply/expected.js @@ -1,6 +1,6 @@ "use strict"; -(function f() { +(function f(n) { var _arguments = arguments, _this = this, _shouldContinue, diff --git a/test/fixtures/transformation/es6-tail-call/expressions/expected.js b/test/fixtures/transformation/es6-tail-call/expressions/expected.js index fe2b8c5d97..b00fec1a5b 100644 --- a/test/fixtures/transformation/es6-tail-call/expressions/expected.js +++ b/test/fixtures/transformation/es6-tail-call/expressions/expected.js @@ -1,6 +1,6 @@ "use strict"; -(function f() { +(function f(n) { var _arguments = arguments, _this = this, _shouldContinue, diff --git a/test/fixtures/transformation/es6-tail-call/recursion/actual.js b/test/fixtures/transformation/es6-tail-call/recursion/actual.js index 9d2b656565..67de2e6943 100644 --- a/test/fixtures/transformation/es6-tail-call/recursion/actual.js +++ b/test/fixtures/transformation/es6-tail-call/recursion/actual.js @@ -1,4 +1,4 @@ -(function f(n, /* should be undefined after first pass */ m) { +(function f(n = getDefaultValue(), /* should be undefined after first pass */ m) { if (n <= 0) { return "foo"; } diff --git a/test/fixtures/transformation/es6-tail-call/recursion/exec.js b/test/fixtures/transformation/es6-tail-call/recursion/exec.js new file mode 100644 index 0000000000..a3098d4c24 --- /dev/null +++ b/test/fixtures/transformation/es6-tail-call/recursion/exec.js @@ -0,0 +1,9 @@ +var timeLimit = Date.now() + 1000; + +assert.equal((function f(n) { + assert.operator(Date.now(), '<', timeLimit, "Timeout"); + if (n <= 0) { + return "foo"; + } + return f(n - 1); +})(1e6), "foo"); diff --git a/test/fixtures/transformation/es6-tail-call/recursion/expected.js b/test/fixtures/transformation/es6-tail-call/recursion/expected.js index d2831ed807..1f5e8fcaf5 100644 --- a/test/fixtures/transformation/es6-tail-call/recursion/expected.js +++ b/test/fixtures/transformation/es6-tail-call/recursion/expected.js @@ -1,13 +1,14 @@ "use strict"; -(function f() { +(function f(_x, /* should be undefined after first pass */m) { var _arguments = arguments, _this = this, _shouldContinue, _result; do { _shouldContinue = false; - _result = (function (n, /* should be undefined after first pass */m) { + _result = (function (_x, m) { + var n = arguments[0] === undefined ? getDefaultValue() : arguments[0]; if (n <= 0) { return "foo"; } diff --git a/test/fixtures/transformation/es6-tail-call/try-catch/expected.js b/test/fixtures/transformation/es6-tail-call/try-catch/expected.js index 0896197b35..cc8434fd01 100644 --- a/test/fixtures/transformation/es6-tail-call/try-catch/expected.js +++ b/test/fixtures/transformation/es6-tail-call/try-catch/expected.js @@ -9,7 +9,7 @@ } catch (e) {} })(1000000) === "foo"; -(function f() { +(function f(n) { var _arguments = arguments, _this = this, _shouldContinue, @@ -43,7 +43,7 @@ } finally {} })(1000000) === "foo"; -(function f() { +(function f(n) { var _arguments = arguments, _this = this, _shouldContinue,