Use plfunc name in type-error messages.

Previously used the name of the C function.
This commit is contained in:
Sage Vaillancourt 2022-04-06 09:55:16 -04:00 committed by Sage Vaillancourt
parent deca6045ff
commit abaf3a1ddc
2 changed files with 3 additions and 3 deletions

View File

@ -528,9 +528,9 @@ Object typeCheck(const char* funcName, Object* params, int length,
} }
for (int i = 0; i < typeLength - 1; i++) { for (int i = 0; i < typeLength - 1; i++) {
if (typeChecks[i].checkFunc && !typeChecks[i].checkFunc(params[i])) { // TODO: Use pl func name instead of C function name. if (typeChecks[i].checkFunc && !typeChecks[i].checkFunc(params[i])) {
char context[128]; char context[128];
sprintf(context, "When calling %s, expected %s, but received %s", funcName, typeChecks[i].name, getTypeName(&params[i])); sprintf(context, "When calling (%s), expected %s, but received %s.", funcName, typeChecks[i].name, getTypeName(&params[i]));
return errorWithContextLineNo(BAD_PARAMS, context, 0, NULL); return errorWithContextLineNo(BAD_PARAMS, context, 0, NULL);
} }
} }

View File

@ -92,7 +92,7 @@ Object typeCheck(const char* funcName, Object* params, int length,
#endif #endif
#ifndef DISABLE_TYPE_CHECKS #ifndef DISABLE_TYPE_CHECKS
#define checkTypes(FUNC) int FAILED; Object ERROR = typeCheck(#FUNC, params, length, FUNC ## TypeChecks, array_length(FUNC ## TypeChecks), &FAILED); \ #define checkTypes(FUNC) int FAILED; Object ERROR = typeCheck(FUNC ## Symbol, params, length, FUNC ## TypeChecks, array_length(FUNC ## TypeChecks), &FAILED); \
if (FAILED) { \ if (FAILED) { \
return ERROR; \ return ERROR; \
} }