summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-03-30 12:55:29 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-03-30 12:55:29 -0700
commit960d5e602c3074afea907b35686482393ada6255 (patch)
tree6d41e045166a466c8f12a8bc72bcbdec9c8c3337
parentfdf176960fee2f2ee2e20c92d1b2d1e3363cf5ce (diff)
downloadtxr-960d5e602c3074afea907b35686482393ada6255.tar.gz
txr-960d5e602c3074afea907b35686482393ada6255.tar.bz2
txr-960d5e602c3074afea907b35686482393ada6255.zip
eval: add missing checks in fun operator.
* eval.c (do_expand): When traversing (fun ...) operator, warn if the function isn't defined or if it is being applied to a special operator.
-rw-r--r--eval.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 73e45fc9..399c61c4 100644
--- a/eval.c
+++ b/eval.c
@@ -4470,6 +4470,19 @@ again:
val arg_ex = expand(arg, menv);
return rlcp(list(sym, arg_ex, nao), form);
}
+ if (!lookup_fun(menv, arg)) {
+ if (special_operator_p(arg))
+ eval_warn(last_form_expanded,
+ lit("fun used on special operator ~s"), arg, nao);
+ else if (!bindable(arg))
+ eval_warn(last_form_expanded,
+ lit("~s appears in operator position"), arg, nao);
+ else
+ eval_defr_warn(last_form_expanded,
+ cons(fun_s, arg),
+ lit("unbound function ~s"),
+ arg, nao);
+ }
return form;
} else if (sym == quote_s || sym == dvbind_s) {
return form;