diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-27 09:05:15 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-27 09:05:15 -0800 |
commit | c924c9ed603bfda6d52d2fca099d42ff2cb02e2c (patch) | |
tree | e4747eb85f1ce738601773a4dcd5ed4e4d333335 | |
parent | b54e6564dade78d3cd673e4640a85c652d3ac656 (diff) | |
download | txr-c924c9ed603bfda6d52d2fca099d42ff2cb02e2c.tar.gz txr-c924c9ed603bfda6d52d2fca099d42ff2cb02e2c.tar.bz2 txr-c924c9ed603bfda6d52d2fca099d42ff2cb02e2c.zip |
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.
-rw-r--r-- | eval.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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); |