From 6b719dccbec69a5c30daf47455c0494c4669c42c Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Sat, 17 Jan 2026 20:37:16 +1100 Subject: [PATCH] Fix bug for functions inside functions --- src/interpreter.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/interpreter.c b/src/interpreter.c index f613259..e8def73 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -272,7 +272,7 @@ GroundFunction* parseFunction(GroundProgram* in, size_t errorOffset) { } } i++; - while (in->instructions[i].type != ENDFUN) { + while (i < in->size) { addInstructionToProgram(&function->program, in->instructions[i]); i++; } @@ -445,37 +445,6 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) { GroundValue gv = createFunctionGroundValue(parseFunction(&gp, errorOffset)); addVariable(scope.variables, name, gv); - /* - char* functionName = in->instructions[i].args.args[0].value.refName; - if (in->instructions[i].args.length < 2) { - function->returnType = NONE; - } else { - if (in->instructions[i].args.args[1].type != TYPEREF) { - runtimeError(ARG_TYPE_MISMATCH, "Expecting a TypeRef for arg 2", &in->instructions[i], i); - } - GroundArg* args = in->instructions[i].args.args; - function->returnType = stringToValueType(args[1].value.refName); - size_t length = in->instructions[i].args.length; - for (size_t j = 2; j < length; j += 2) { - if (args[j].type != TYPEREF) { - runtimeError(ARG_TYPE_MISMATCH, "Expecting a TypeRef", &in->instructions[i], i); - } - if (j + 1 >= length) { - runtimeError(TOO_FEW_ARGS, "Expecting a DirectRef after a TypeRef", &in->instructions[i], i); - } - if (args[j + 1].type != DIRREF) { - runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef after a TypeRef", &in->instructions[i], i); - } - addArgsToGroundFunction(function, stringToValueType(args[j].value.refName), args[j + 1].value.refName); - } - } - i++; - while (in->instructions[i].type != ENDFUN) { - addInstructionToProgram(&function->program, in->instructions[i]); - i++; - } - addVariable(scope.variables, functionName, createFunctionGroundValue(function)); - */ } if (in->instructions[i].type == STRUCT) { if (in->instructions[i].args.length < 1) {