From c924c9ed603bfda6d52d2fca099d42ff2cb02e2c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 27 Nov 2016 09:05:15 -0800 Subject: bugfix: var environment in expansion of defun. * eval.c (do_expand): When expanding the body of a defun we must create a function shadowing environment which indicates that the function's name is in scope. This must not be done for defmacro; a defmacro doesn't introduce a function binding, and a macros's body doesn't have that macro in scope. --- eval.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index e4ad8859..c15ef1c5 100644 --- a/eval.c +++ b/eval.c @@ -3726,7 +3726,10 @@ static val do_expand(val form, val menv) check_lambda_list(form, sym, params); { - val new_menv = make_var_shadowing_env(menv, get_param_syms(params)); + val inter_env = make_var_shadowing_env(menv, get_param_syms(params)); + val new_menv = if3(sym == defun_s, + make_fun_shadowing_env(inter_env, cons(name, nil)), + inter_env); val params_ex = expand_params(params, menv); val body = rest(rest(rest(form))); val body_ex = expand_progn(body, new_menv); -- cgit v1.2.3