Fixed an argument list bug, found a casting bug

This commit is contained in:
2022-09-03 16:04:18 +01:00
parent 32d6b7124c
commit 86061cb74e
2 changed files with 19 additions and 0 deletions

12
scripts/fib.toy Normal file
View File

@@ -0,0 +1,12 @@
fn fib(n : int) {
if (n < 2) {
return n;
}
return fib(n-1) + fib(n-2);
}
for (var i = 0; i < 40; i++) {
var res = fib(i);
print (string)i + ": " + (string)res;
}

View File

@@ -1450,6 +1450,13 @@ static bool execFnCall(Interpreter* interpreter) {
}
Literal arg = popLiteralArray(&arguments);
if (IS_IDENTIFIER(arg)) {
Literal idn = arg;
parseIdentifierToValue(interpreter, &arg);
freeLiteral(idn);
}
if (!setScopeVariable(inner.scope, paramArray->literals[i], arg, false)) {
printf(ERROR "[internal] Could not define parameter (bad type?)\n" RESET);
//free, and skip out