From 260173b6ad42a4643e6cde9ead210234bd47f545 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 12 Apr 2016 03:57:11 -0700 Subject: Don't expand replacements of symbol macros. * eval.c (expand_symacrolet, do_expand): Don't expand the replacement form of a global or lexical symbol macro at the time it is bound to its symbol. This is almost certainly wrong in situations where it makes a difference. * txr.1: Noted in compatibility section. --- eval.c | 9 ++++++--- share/txr/stdlib/place.tl | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/eval.c b/eval.c index 41688074..d4ec01a9 100644 --- a/eval.c +++ b/eval.c @@ -1712,8 +1712,9 @@ static val expand_symacrolet(val form, val menv) val macro = car(symacs); val name = pop(¯o); val repl = pop(¯o); - val repl_ex = expand(repl, menv); - env_vbind(new_env, name, repl_ex); + env_vbind(new_env, name, + if3(opt_compat && opt_compat <= 137, + expand(repl, menv), repl)); } return maybe_progn(expand_forms(body, new_env)); @@ -3392,7 +3393,9 @@ tail: form_ex = rlcp(cons(sym, cons(name, cons(init_ex, nil))), form); if (sym == defsymacro_s) { - val result = eval(form_ex, make_env(nil, nil, nil), form); + val result = eval(if3(opt_compat && opt_compat <= 137, + form_ex, form), + make_env(nil, nil, nil), form); return cons(quote_s, cons(result, nil)); } else { mark_special(name); diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index 5d17acb7..68567ed1 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -312,8 +312,8 @@ (getter-sym setter-sym update-body) : ((ssetter-sym clobber-body)) ((deleter-sym delete-body))) - (symacrolet ((name (car place-destructuring-args)) - (args (cdr place-destructuring-args))) + (let ((name (car place-destructuring-args)) + (args (cdr place-destructuring-args))) (unless (and name (symbolp name) (not (keywordp name)) -- cgit v1.2.3