diff --git a/scripts/small.toy b/scripts/small.toy index 1a1ab9c..febace3 100644 --- a/scripts/small.toy +++ b/scripts/small.toy @@ -2,18 +2,11 @@ fn capture(count: int) { print count; print capture; - if (count < 5) { + if (count > 5) { return count; } - print count; - print capture; - - count++; - count++; - -// return capture(count + 1); - return -1; + return capture(count + 1); } -print capture(52); +print capture(0); diff --git a/scripts/test/functions.toy b/scripts/test/functions.toy index c34c410..9e9f2f7 100644 --- a/scripts/test/functions.toy +++ b/scripts/test/functions.toy @@ -39,7 +39,7 @@ fn capture(count: int) { return capture(count + 1); } -assert capture(0) == 5, "Self capture failed"; +assert capture(0) == 6, "Self capture failed"; //test expressions as arguments diff --git a/source/interpreter.c b/source/interpreter.c index d641707..0bb49c4 100644 --- a/source/interpreter.c +++ b/source/interpreter.c @@ -1469,7 +1469,7 @@ static bool execFnCall(Interpreter* interpreter) { } freeLiteral(restType); - freeLiteral(lit); + freeLiteralArray(&rest); } //execute the interpreter