Works across functions and generates simpler and faster code than #701. Works even across files when used in conjunction with `runtime` option. Closes #256.
42 lines
662 B
JavaScript
42 lines
662 B
JavaScript
"use strict";
|
|
|
|
(function f(n) {
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
try {
|
|
return f(n - 1);
|
|
} catch (e) {}
|
|
})(1000000) === "foo";
|
|
|
|
(function f(n) {
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
try {
|
|
throw new Error();
|
|
} catch (e) {
|
|
return to5Runtime.tailCall(f, [n - 1]);
|
|
}
|
|
})(1000000) === "foo";
|
|
|
|
(function f(n) {
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
try {
|
|
throw new Error();
|
|
} catch (e) {
|
|
return f(n - 1);
|
|
} finally {}
|
|
})(1000000) === "foo";
|
|
|
|
(function f(n) {
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
try {} finally {
|
|
return to5Runtime.tailCall(f, [n - 1]);
|
|
}
|
|
})(1000000) === "foo";
|