core: Show more info on apply error.
* mes.c (apply_env): Be more specific about what cannot be applied.
This commit is contained in:
parent
c121fe3d72
commit
07778d3b70
24
mes.c
24
mes.c
|
@ -392,12 +392,24 @@ apply_env (scm *fn, scm *x, scm *a)
|
||||||
else if (fn->car == &scm_label)
|
else if (fn->car == &scm_label)
|
||||||
return apply_env (caddr (fn), x, cons (cons (cadr (fn), caddr (fn)), a));
|
return apply_env (caddr (fn), x, cons (cons (cadr (fn), caddr (fn)), a));
|
||||||
#endif
|
#endif
|
||||||
scm *efn = eval_env (fn, a);
|
scm *e = eval_env (fn, a);
|
||||||
if (efn == &scm_f || efn == &scm_t) assert (!"apply bool");
|
char const* type = 0;
|
||||||
if (efn->type == NUMBER) assert (!"apply number");
|
if (e == &scm_f || e == &scm_t) type = "bool";
|
||||||
if (efn->type == STRING) assert (!"apply string");
|
if (e->type == CHAR) type = "char";
|
||||||
if (efn == &scm_unspecified) assert (!"apply *unspecified*");
|
if (e->type == NUMBER) type = "number";
|
||||||
return apply_env (efn, x, a);
|
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 *
|
scm *
|
||||||
|
|
Loading…
Reference in New Issue