From db93ff2b362952114d7dc1030434c8a9c8e1034b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 30 Apr 2018 23:24:11 -0700 Subject: expander: regression in param list treatment. Change ca6199a that went into TXR 191 was over-zealous in suppressing expand_param_rec calls for non-macro argument processing. The recursive calls are needed in order to detect parameters that are special variables and add them to pspecials. The upshot is that usage such as the following broke: (lambda (*stdout*) ...) because expand_param_rec isn't called on the *stdout* symbol and *stdout* is thus not noted as a special variable, and thus the expander then neglects to produce (sys:with-dyn-rebinds (*stdout*) ...) around the body of the lambda. The new compiler introduced at the same time made this harder to find. Why? Because the compiler ignores the sys:with-dyn-rebinds special form; it implements its own handling for specials in lambda and let! So compiled code is unaffected by this regression. * eval.c (expand_opt_params_rec): Call expand_params_rec on the car of the optional var-init pair, whether or not expanding a macro style parameter. (expand_params_rec): Call expand_params_rec recursively on any parameter that is bindable whether or not in macro mode. The two cases fold together again, and so here we see that the recent fix d934a3e was also a regression caused by ca6199a. --- eval.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/eval.c b/eval.c index e38770d3..957c68d8 100644 --- a/eval.c +++ b/eval.c @@ -920,9 +920,9 @@ static val expand_opt_params_rec(val params, val menv, car(form), car(pair), nao); } else { val param = car(pair); - val param_ex = if3(macro_style_p && consp(param), - expand_params_rec(param, menv, t, form, pspecials), - param); + val param_ex = expand_params_rec(param, menv, + macro_style_p, + form, pspecials); val initform = cadr(pair); val initform_ex = rlcp(expand(initform, menv), initform); val opt_sym = caddr(pair); @@ -988,14 +988,11 @@ static val expand_params_rec(val params, val menv, eval_error(form, lit("~s: ~s parameter requires bindable symbol"), car(form), param, nao); param_ex = param; - } else if (macro_style_p && (nilp(param) || consp(param))) { + } else if (bindable(param) || (macro_style_p && listp(param))) { param_ex = expand_params_rec(param, menv, t, form, pspecials); new_menv = make_var_shadowing_env(menv, get_param_syms(param_ex)); - } else if (!bindable(param)) { - not_bindable_error(form, param); } else { - param_ex = param; - new_menv = make_var_shadowing_env(menv, cons(param, nil)); + not_bindable_error(form, param); } { -- cgit v1.2.3