summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index deed3ede..ab7518f6 100644
--- a/eval.c
+++ b/eval.c
@@ -1911,6 +1911,20 @@ static val expand_macro(val form, val mac_binding, val menv)
{
val expander = cdr(mac_binding);
val expanded = funcall2(expander, form, menv);
+ if (form == expanded) {
+ val sym = car(form);
+ val up_binding = mac_binding;
+
+ while (menv && up_binding == mac_binding) {
+ menv = menv->e.up_env;
+ up_binding = lookup_mac(menv, sym);
+ }
+
+ if (up_binding && up_binding != mac_binding)
+ return expand_macro(form, up_binding, menv);
+
+ return form;
+ }
set_origin(expanded, form);
return expanded;
}