From 291f788ebfd09702b47973301a56e89aadf76b49 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 3 Apr 2018 20:57:55 -0700 Subject: compiler: rewrite incorrect defmacro expander. * share/txr/stdlib/compiler.tl (expand-defmacro): We cannot simply generate a mac-param-bind form because that has no means to pass through the all-important macro environment parameter; its expansion is carried out by expand-bind-mac-params with an nil environment parameter. Instead, we retarget to use expand-bind-mac-params directly, and supply the parameter gensym. --- share/txr/stdlib/compiler.tl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index aafbf5f0..a4721448 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -1277,13 +1277,15 @@ (defun expand-defmacro (form) (mac-param-bind form (op name mac-args . body) form - (with-gensyms (form menv) + (with-gensyms (form menv spine-iter) (let ((exp-lam ^(lambda (,form ,menv) - (mac-param-bind ,form ,mac-args (cdr ,form) - (sys:set-macro-ancestor - (block ,name - ,*body) - ,form))))) + (let ((,spine-iter (cdr ,form))) + ,(expand (expand-bind-mac-params form form mac-args + menv spine-iter + t nil + ^((sys:set-macro-ancestor + (block ,name ,*body) + ,form)))))))) ^(progn (sys:rt-defmacro ',name '(macro ,name) ,exp-lam) ',name))))) -- cgit v1.2.3