diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-15 07:47:29 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-15 07:47:29 -0700 |
commit | 5a584a973b632f28edcc0312d92e4a38ee567d8c (patch) | |
tree | be339f33937f3a883172939d7e82b35233421d43 /tests/011 | |
parent | 561428042eeb26eb0d5c05c3985bd4c8ecdcec1d (diff) | |
download | txr-5a584a973b632f28edcc0312d92e4a38ee567d8c.tar.gz txr-5a584a973b632f28edcc0312d92e4a38ee567d8c.tar.bz2 txr-5a584a973b632f28edcc0312d92e4a38ee567d8c.zip |
defsymacro: regression: don't expand replacement.
This is a regression that was introduced in 191. The change in
191 was trying to prevent defsymacro from being expanded
immediately by the expander except in 190 compatibility.
Unfortunately, this caused the whole defsymacro block not to
be entered unless in 190 compatibility, otherwise taking the
common exit which returns form_ex, containing the expanded
replacement form.
* eval.c (do_expand): Split up implementation of defvarl and
defsymacro. In the defsymacro block, do not do any expanding
on entry. Absent of compatibility mode, we just do some sanity
checks and pass the entire form through. In 262 compatibility,
we do the expansion to obtain form_ex. Then all the previous
compat logic is wrapped in that block.
* tests/011/macros-3.tl: Add a test case which confirms that
symbol macros are lazily expanded. Weakness in the test suite
is how these regressions creep in.
* txr.1: Improve defsymacro documentation, spelling out
clearly that the unexpanded replacement form is associated
with the symbol. Eliminate obsolescent text suggesting that
defsymacro is evaluated at macro time.
Diffstat (limited to 'tests/011')
-rw-r--r-- | tests/011/macros-3.tl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/011/macros-3.tl b/tests/011/macros-3.tl index bf7cf9a6..e08e5da7 100644 --- a/tests/011/macros-3.tl +++ b/tests/011/macros-3.tl @@ -10,3 +10,11 @@ (macrolet ((m (:form f) f)) (m)))))) 42) + +(defvar x 0) +(defmacro mac-time-counter () (inc x)) +(defsymacro s (mac-time-counter)) + +(mtest s 1 + s 2 + s 3) |