summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-03-25 21:01:42 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-03-25 21:01:42 -0700
commit4c6d387b73dca86caed48b1e786c5c1bc2c4716b (patch)
tree2e8befca903768b686575d3c688caf70a8f62ced
parent8bb9e6c295814880f1b812056027b7b4e9dda161 (diff)
downloadtxr-4c6d387b73dca86caed48b1e786c5c1bc2c4716b.tar.gz
txr-4c6d387b73dca86caed48b1e786c5c1bc2c4716b.tar.bz2
txr-4c6d387b73dca86caed48b1e786c5c1bc2c4716b.zip
* eval.c (expand_quasi): Bugfix: incorrect logic, failing
to macro-expand the embedded forms in a quasiliteral except when they are the very first item.
-rw-r--r--ChangeLog6
-rw-r--r--eval.c19
2 files changed, 17 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 1ae8a0d2..2ba9aa05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2014-03-25 Kaz Kylheku <kaz@kylheku.com>
+ * eval.c (expand_quasi): Bugfix: incorrect logic, failing
+ to macro-expand the embedded forms in a quasiliteral except
+ when they are the very first item.
+
+2014-03-25 Kaz Kylheku <kaz@kylheku.com>
+
* parser.y (yybadtoken): Add missing cases for new token
types WORDS and WSPLICE.
diff --git a/eval.c b/eval.c
index c502800f..5c783371 100644
--- a/eval.c
+++ b/eval.c
@@ -2220,22 +2220,25 @@ static val expand_quasi(val quasi_forms, val menv)
val form = first(quasi_forms);
val form_ex = form;
- if (atom(form)) {
- form_ex = form;
- } else {
+ if (consp(form)) {
val sym = car(form);
if (sym == expr_s) {
val expr_ex = expand(rest(form), menv);
if (expr_ex != rest(form))
form_ex = rlcp(cons(sym, expr_ex), form);
- }
+ }
}
- if (form != form_ex)
- return rlcp(cons(form_ex, expand_quasi(rest(quasi_forms), menv)),
- quasi_forms);
- return quasi_forms;
+ {
+ val rest_forms = rest(quasi_forms);
+ val rest_ex = expand_quasi(rest_forms, menv);
+
+ if (form == form_ex && rest_ex == rest_forms)
+ return quasi_forms;
+
+ return rlcp(cons(form_ex, rest_ex), quasi_forms);
+ }
}
}