tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit 8bc2a53e03e40a5c4694a323390a8d0c01b8a5a7
parent 2203bdd7da2f51dcdc8662ab2008efac8c8169eb
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Sat, 21 Sep 2019 16:38:19 -0700

Error if function name is not symbol

Diffstat:
tisp.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tisp.c b/tisp.c @@ -936,7 +936,11 @@ prim_define(Env env, Val args) tsp_warnf("define: expected 2 or more arguments, received %d", list_len(args)); if (car(args)->t == PAIR) { sym = caar(args); - val = mk_func(FUNCTION, cdar(args), cdr(args), env); + if (sym->t != SYMBOL) + tsp_warnf("define: incorrect format," + " expected symbol for function name, received %s", + type_str(sym->t)); + val = mk_func(FUNCTION, cdar(args), cdr(args), env); /* TODO copy env into new env */ } else if (car(args)->t == SYMBOL) { sym = car(args); val = tisp_eval(env, cadr(args));