From 1d3d115e1f50d1f1feaec7d409c853621b8d939f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 30 Oct 2019 19:50:32 -0700 Subject: expander: bogus undefined warnings from lisp1 values. Issue: (sys:lisp1-value x) throws a warning even if x is a predefined library function. This is caused by naively using expand to attempt to expand it as a symbol macro. * eval.c (expand_lisp1_value): Use expand_lisp1 instead of expand, just like expand_forms_lisp1. Because I didn't notice this problem when adding those two functions, expand_lisp1 is farther down the file and we need a forward declaration. (expand_lisp1_setq): Likewise, and eliminate the unbound variable check which is done by expand_lisp1. --- eval.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/eval.c b/eval.c index 777858c3..837e20e2 100644 --- a/eval.c +++ b/eval.c @@ -2344,14 +2344,16 @@ static val op_lisp1_setq(val form, val env) return sys_rplacd(binding, eval(newval, env, form)); } +static val expand_lisp1(val form, val menv); + static val expand_lisp1_value(val form, val menv) { if (length(form) != two) eval_error(form, lit("~s: invalid syntax"), first(form), nao); { - val sym = second(form); - val sym_ex = expand(sym, menv); + val sym = cadr(form); + val sym_ex = expand_lisp1(sym, menv); val binding_type = lexical_lisp1_binding(menv, sym_ex); if (nilp(binding_type)) { @@ -2380,7 +2382,7 @@ static val expand_lisp1_setq(val form, val menv) { val op = car(form); val sym = cadr(form); - val sym_ex = expand(sym, menv); + val sym_ex = expand_lisp1(sym, menv); val newval = caddr(form); val binding_type = lexical_lisp1_binding(menv, sym_ex); @@ -2388,11 +2390,6 @@ static val expand_lisp1_setq(val form, val menv) if (!bindable(sym_ex)) eval_error(form, lit("~s: misapplied to form ~s"), op, sym_ex, nao); - if (!lookup_var(nil, sym_ex) && !lookup_fun(nil, sym_ex)) - eval_defr_warn(uw_last_form_expanded(), - cons(var_s, sym_ex), - lit("~s: unbound variable/function ~s"), - op, sym_ex, nao); return rlcp(cons(op, cons(sym_ex, cons(expand(newval, menv), nil))), form); } -- cgit v1.2.3