mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Changed recursion limit to 10,000 (was 200)
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
var s = "42";
|
||||
var t = "69";
|
||||
|
||||
print int (s + t) - 1;
|
||||
17
scripts/test_sum.js
Normal file
17
scripts/test_sum.js
Normal file
@@ -0,0 +1,17 @@
|
||||
//the test case (js)
|
||||
function test_sum(key, val) {
|
||||
function sum(n) {
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
return n + sum(n - 1);
|
||||
}
|
||||
|
||||
const result = sum(val);
|
||||
console.log(`${key}: ${result}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i <= 10; i++) {
|
||||
test_sum(i, i * 1000);
|
||||
}
|
||||
17
scripts/test_sum.toy
Normal file
17
scripts/test_sum.toy
Normal file
@@ -0,0 +1,17 @@
|
||||
//the test case (toy)
|
||||
fn test_sum(key: int, val: int) {
|
||||
fn sum(n: int) {
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
return n + sum(n - 1);
|
||||
}
|
||||
|
||||
var result: int const = sum(val);
|
||||
print string key + ": " + string result;
|
||||
}
|
||||
|
||||
for (var i: int = 0; i <= 10; i++) {
|
||||
test_sum(i, i * 1000);
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ static void readInterpreterSections(Toy_Interpreter* interpreter);
|
||||
//also supports identifier & arg1 to be other way around (looseFirstArgument)
|
||||
static bool execFnCall(Toy_Interpreter* interpreter, bool looseFirstArgument) {
|
||||
//BUGFIX: depth check - don't drown!
|
||||
if (interpreter->depth >= 200) {
|
||||
if (interpreter->depth >= 1000 * 10) {
|
||||
interpreter->errorOutput("Infinite recursion detected - panicking\n");
|
||||
interpreter->panic = true;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user