bug fixes

This commit is contained in:
2026-07-03 10:29:21 +10:00
parent c78426ef88
commit a06d3ba55d
4 changed files with 16 additions and 11 deletions

View File

@@ -14,7 +14,7 @@ GroundProgram _GroundProgramPreprocess(GroundProgram* program, GroundState* stat
GroundInstruction* sig = &program->at[i];
char* id = sig->args.at[0].as.ref->string;
for (GroundSize j = 1; i < sig->args.len - 1; i++) {
for (GroundSize j = 1; j < sig->args.len; j++) {
GroundArg* arg = &sig->args.at[j];
// Ignore type annotations, this can be taken care of in another function
@@ -23,6 +23,16 @@ GroundProgram _GroundProgramPreprocess(GroundProgram* program, GroundState* stat
}
char* argId = arg->as.ref->string;
Ground.Function.appendArg(&function, argId);
GroundVariable* argVar = malloc(sizeof(GroundVariable));
if (argVar == NULL) {
Ground.Flags.error = true;
Ground.Log.Error("malloc failed in Ground.Program.Preprocess");
return newProgram;
}
snprintf(argVar->name, 2047, "%s", argId);
argVar->value = Ground.New.Value.Int(0);
HASH_ADD_STR(function.closure->variables, name, argVar);
}
// Add instructions to function