handle TCO for calls that exceed the functions parameter count - fixes #1589
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
var count = (i = 10) => {
|
||||
if (!i) return;
|
||||
return count(i - 1);
|
||||
};
|
||||
|
||||
function count2(i = 10) {
|
||||
if (!i) return;
|
||||
return count2(i - 1);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
var count = function count() {
|
||||
var _arguments = arguments;
|
||||
var _again = true;
|
||||
|
||||
_function: while (_again) {
|
||||
i = undefined;
|
||||
_again = false;
|
||||
var i = _arguments[0] === undefined ? 10 : _arguments[0];
|
||||
|
||||
if (!i) return;
|
||||
_arguments = [i - 1];
|
||||
_again = true;
|
||||
continue _function;
|
||||
}
|
||||
};
|
||||
|
||||
function count2() {
|
||||
var _arguments2 = arguments;
|
||||
var _again2 = true;
|
||||
|
||||
_function2: while (_again2) {
|
||||
i = undefined;
|
||||
_again2 = false;
|
||||
var i = _arguments2[0] === undefined ? 10 : _arguments2[0];
|
||||
|
||||
if (!i) return;
|
||||
_arguments2 = [i - 1];
|
||||
_again2 = true;
|
||||
continue _function2;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user