summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-03 20:57:55 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-03 20:57:55 -0700
commit291f788ebfd09702b47973301a56e89aadf76b49 (patch)
treec4885643f104500482d52f056d8477add1d489c7
parentafad01168d6506a828eb7cd76e5e06ef02733501 (diff)
downloadtxr-291f788ebfd09702b47973301a56e89aadf76b49.tar.gz
txr-291f788ebfd09702b47973301a56e89aadf76b49.tar.bz2
txr-291f788ebfd09702b47973301a56e89aadf76b49.zip
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.
-rw-r--r--share/txr/stdlib/compiler.tl14
1 files 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)))))