From 1b8559f0ef8d79212bc694ef3fadd2ac1cb08159 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sat, 3 Sep 2022 08:45:06 +0100 Subject: [PATCH] Squashing bugs --- scripts/small.toy | 13 +++---------- scripts/test/functions.toy | 2 +- source/interpreter.c | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) 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