diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-10-30 19:50:32 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-10-30 19:50:32 -0700 |
commit | 1d3d115e1f50d1f1feaec7d409c853621b8d939f (patch) | |
tree | 6c1328e22c6db746e852886250b6049aafdd9146 /eval.c | |
parent | d131be5ddd9758bc497ed5eb686b21d05b8aa5c8 (diff) | |
download | txr-1d3d115e1f50d1f1feaec7d409c853621b8d939f.tar.gz txr-1d3d115e1f50d1f1feaec7d409c853621b8d939f.tar.bz2 txr-1d3d115e1f50d1f1feaec7d409c853621b8d939f.zip |
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.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -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); } |