summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-03-08 08:15:42 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-03-08 08:15:42 -0800
commit6438a2e747c834da59fbaf1704a72b184d40c5d8 (patch)
treeb60f2d2c9c15eec8a3ccd4ea8d622269c70247ae
parent4687dad975105144fd04827ca525a6272102b9d0 (diff)
downloadtxr-6438a2e747c834da59fbaf1704a72b184d40c5d8.tar.gz
txr-6438a2e747c834da59fbaf1704a72b184d40c5d8.tar.bz2
txr-6438a2e747c834da59fbaf1704a72b184d40c5d8.zip
expander: tree-bind: fix incorrect param env.
* eval.c (do_expand): A wrong thing is being done here: the macro is extended using the original parameter syntax, that has not been processed by expand_params. The body is then expanded using that environment. This subtly breaks support for parameter macros in tree-bind. They work, but there are spurious warnings about undefined variables during expansion, and the wrong scope handling can introduce bugs. The right thing is to derive new_menv by pulling the parameter symbols from params_ex.
-rw-r--r--eval.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index dccf3fbd..a3b593ef 100644
--- a/eval.c
+++ b/eval.c
@@ -4673,10 +4673,10 @@ again:
val params = pop(&args);
val expr = pop(&args);
val body = args;
- val new_menv = make_var_shadowing_env(menv, get_param_syms(params));
- val ctx_expr_ex = expand(ctx_expr, menv);
cons_bind (params_ex, body_ex0,
expand_params(params, body, menv, t, form));
+ val new_menv = make_var_shadowing_env(menv, get_param_syms(params_ex));
+ val ctx_expr_ex = expand(ctx_expr, menv);
val body_ex = expand_progn(body_ex0, new_menv);
val expr_ex = expand(expr, new_menv);