forked from ground/ground
I think any should work now
This commit is contained in:
@@ -1900,11 +1900,11 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
|||||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
|
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
|
||||||
}
|
}
|
||||||
if (function->nativeFn) {
|
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);
|
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1922,7 +1922,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
|||||||
}
|
}
|
||||||
return returnValue;
|
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);
|
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);
|
addVariable(scope->variables, in->args.args[in->args.length - 1].value.refName, returnValue);
|
||||||
@@ -1931,11 +1931,10 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
|||||||
} else {
|
} else {
|
||||||
GroundScope newScope = copyGroundScope(&function->closure);
|
GroundScope newScope = copyGroundScope(&function->closure);
|
||||||
for (size_t i = 0; i < function->argSize; i++) {
|
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);
|
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 || function->args[i].type == ANY || !checkFnTypes(&in->args.args[i + 1].value.value, &function->args[i])) {
|
||||||
if (!checkFnTypes(&in->args.args[i + 1].value.value, &function->args[i])) {
|
|
||||||
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
|
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
|
||||||
}
|
}
|
||||||
addVariable(newScope.variables, function->args[i].name, in->args.args[i + 1].value.value);
|
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) {
|
if (returnValue.type == ERROR) {
|
||||||
return returnValue;
|
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);
|
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);
|
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
|
||||||
}
|
}
|
||||||
if (function->nativeFn) {
|
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);
|
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2047,7 +2046,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
if (returnValue.type != function->returnType) {
|
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);
|
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);
|
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value", in, currentInstruction);
|
||||||
}
|
}
|
||||||
//if (in->args.args[i + 1].value.value.type != function->args[i].type) {
|
//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);
|
runtimeError(ARG_TYPE_MISMATCH, "Mismatched function argument types", in, currentInstruction);
|
||||||
}
|
}
|
||||||
addVariable(newScope.variables, function->args[i].name, in->args.args[i + 2].value.value);
|
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) {
|
if (returnValue.type == ERROR) {
|
||||||
return returnValue;
|
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);
|
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);
|
addVariable(scope->variables, in->args.args[in->args.length - 1].value.refName, returnValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user