I think any should work now

This commit is contained in:
2026-04-11 19:24:46 +10:00
parent 5b01784011
commit 7b893dd931

View File

@@ -1900,11 +1900,11 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
}
if (function->nativeFn) {
if (in->args.args[i + 1].value.value.type != function->args[i].type) {
if (function->args[i].type == ANY || in->args.args[i + 1].value.value.type != function->args[i].type) {
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
}
} else {
if (!checkFnTypes(&in->args.args[i + 1].value.value, &function->args[i])) {
if (function->args[i].type == ANY || !checkFnTypes(&in->args.args[i + 1].value.value, &function->args[i])) {
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
}
}
@@ -1922,7 +1922,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
}
return returnValue;
}
if (returnValue.type != function->returnType) {
if (returnValue.type == ANY || returnValue.type != function->returnType) {
runtimeError(RETURN_TYPE_MISMATCH, "Unexpected return value type from native function", in, currentInstruction);
}
addVariable(scope->variables, in->args.args[in->args.length - 1].value.refName, returnValue);
@@ -1931,11 +1931,10 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
} else {
GroundScope newScope = copyGroundScope(&function->closure);
for (size_t i = 0; i < function->argSize; i++) {
if (in->args.args[i + 1].type != VALUE) {
if (function->args[i].type == ANY || in->args.args[i + 1].type != VALUE) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
}
//if (in->args.args[i + 1].value.value.type != function->args[i].type) {
if (!checkFnTypes(&in->args.args[i + 1].value.value, &function->args[i])) {
if (function->args[i].type == ANY || function->args[i].type == ANY || !checkFnTypes(&in->args.args[i + 1].value.value, &function->args[i])) {
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
}
addVariable(newScope.variables, function->args[i].name, in->args.args[i + 1].value.value);
@@ -1946,7 +1945,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
if (returnValue.type == ERROR) {
return returnValue;
}
if (returnValue.type != function->returnType) {
if (function->returnType == ANY || returnValue.type != function->returnType) {
runtimeError(RETURN_TYPE_MISMATCH, "Unexpected return value type from function", in, currentInstruction);
}
@@ -2005,11 +2004,11 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
}
if (function->nativeFn) {
if (in->args.args[i + 2].value.value.type != function->args[i].type) {
if (function->args[i].type == ANY || in->args.args[i + 2].value.value.type != function->args[i].type) {
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
}
} else {
if (!checkFnTypes(&in->args.args[i + 2].value.value, &function->args[i])) {
if (function->args[i].type == ANY || !checkFnTypes(&in->args.args[i + 2].value.value, &function->args[i])) {
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
}
}
@@ -2047,7 +2046,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
return returnValue;
}
if (returnValue.type != function->returnType) {
runtimeError(RETURN_TYPE_MISMATCH, "Unexpected return value type from native function", in, currentInstruction);
runtimeError(function->returnType == ANY || RETURN_TYPE_MISMATCH, "Unexpected return value type from native function", in, currentInstruction);
}
addVariable(scope->variables, in->args.args[in->args.length - 1].value.refName, returnValue);
@@ -2064,7 +2063,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
}
//if (in->args.args[i + 1].value.value.type != function->args[i].type) {
if (!checkFnTypes(&in->args.args[i + 2].value.value, &function->args[i])) {
if (function->args[i].type == ANY || !checkFnTypes(&in->args.args[i + 2].value.value, &function->args[i])) {
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
}
addVariable(newScope.variables, function->args[i].name, in->args.args[i + 2].value.value);
@@ -2077,7 +2076,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
if (returnValue.type == ERROR) {
return returnValue;
}
if (returnValue.type != function->returnType) {
if (function->returnType == ANY || returnValue.type != function->returnType) {
runtimeError(RETURN_TYPE_MISMATCH, "Unexpected return value type from function", in, currentInstruction);
}
addVariable(scope->variables, in->args.args[in->args.length - 1].value.refName, returnValue);