From abaf3a1ddc6ec11c034a1f63eb7d0d1cb6601541 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Apr 2022 09:55:16 -0400 Subject: [PATCH] Use plfunc name in type-error messages. Previously used the name of the C function. --- src/pebblisp.c | 4 ++-- src/pebblisp.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pebblisp.c b/src/pebblisp.c index 2676a40..092a2d7 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -528,9 +528,9 @@ Object typeCheck(const char* funcName, Object* params, int length, } 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]; - sprintf(context, "When calling %s, expected %s, but received %s", funcName, typeChecks[i].name, getTypeName(¶ms[i])); + sprintf(context, "When calling (%s), expected %s, but received %s.", funcName, typeChecks[i].name, getTypeName(¶ms[i])); return errorWithContextLineNo(BAD_PARAMS, context, 0, NULL); } } diff --git a/src/pebblisp.h b/src/pebblisp.h index f4ff740..e3ebc8c 100644 --- a/src/pebblisp.h +++ b/src/pebblisp.h @@ -92,7 +92,7 @@ Object typeCheck(const char* funcName, Object* params, int length, #endif #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) { \ return ERROR; \ }