fix any again

This commit is contained in:
2026-04-11 19:33:58 +10:00
parent 93c6989890
commit a1ad1fe139

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 (function->args[i].type == ANY || 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 (function->args[i].type == ANY || !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 == ANY || 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);
@@ -1934,7 +1934,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
if (in->args.args[i + 1].type != VALUE) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
}
if (function->args[i].type == ANY || function->args[i].type == ANY || !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);
}
addVariable(newScope.variables, function->args[i].name, in->args.args[i + 1].value.value);
@@ -1945,7 +1945,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
if (returnValue.type == ERROR) {
return returnValue;
}
if (function->returnType == ANY || returnValue.type != function->returnType) {
if (function->returnType != ANY && returnValue.type != function->returnType) {
runtimeError(RETURN_TYPE_MISMATCH, "Unexpected return value type from function", in, currentInstruction);
}
@@ -2004,11 +2004,11 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
}
if (function->nativeFn) {
if (function->args[i].type == ANY || 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 (function->args[i].type == ANY || !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);
}
}
@@ -2045,8 +2045,8 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
}
return returnValue;
}
if (returnValue.type != function->returnType) {
runtimeError(function->returnType == ANY || RETURN_TYPE_MISMATCH, "Unexpected return value type from native function", in, currentInstruction);
if (function->returnType != 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);
@@ -2063,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 (function->args[i].type == ANY || !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);
@@ -2076,7 +2076,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
if (returnValue.type == ERROR) {
return returnValue;
}
if (function->returnType == ANY || 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);