From 07778d3b7079e5d6aff449b08ba9691fd9c2dea5 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 5 Nov 2016 15:33:16 +0100 Subject: [PATCH] core: Show more info on apply error. * mes.c (apply_env): Be more specific about what cannot be applied. --- mes.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mes.c b/mes.c index 8b5eafb9..0a5504e0 100644 --- a/mes.c +++ b/mes.c @@ -392,12 +392,24 @@ apply_env (scm *fn, scm *x, scm *a) else if (fn->car == &scm_label) return apply_env (caddr (fn), x, cons (cons (cadr (fn), caddr (fn)), a)); #endif - scm *efn = eval_env (fn, a); - if (efn == &scm_f || efn == &scm_t) assert (!"apply bool"); - if (efn->type == NUMBER) assert (!"apply number"); - if (efn->type == STRING) assert (!"apply string"); - if (efn == &scm_unspecified) assert (!"apply *unspecified*"); - return apply_env (efn, x, a); + scm *e = eval_env (fn, a); + char const* type = 0; + if (e == &scm_f || e == &scm_t) type = "bool"; + if (e->type == CHAR) type = "char"; + if (e->type == NUMBER) type = "number"; + if (e->type == STRING) type = "string"; + if (e == &scm_unspecified) type = "*unspecified*"; + if (e == &scm_undefined) type = "*undefined*"; + if (type) + { + fprintf (stderr, "cannot apply: %s: ", type); + display_ (stderr, e); + fprintf (stderr, " ("); + display_ (stderr, fn); + fprintf (stderr, ")\n"); + assert (!"cannot apply"); + } + return apply_env (e, x, a); } scm *