From bbb79a948de4688b44ba18ae37a1a6abb30e84d7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 24 May 2023 07:31:16 -0700 Subject: label/flet: bug: empty case wallops symbol macros. * eval.c (make_var_shadowing_env): We cannot return the original env in the empty variable case, but earnestly make a new one. This function is used by the expander when walking the lbind/fbind special from emitted by labels/flet. That form clobbers the environment via make_fun_shadowing_env, which calls make_var_shadowing_env and then destructively moves the variable bindings to the function binding slot of the environment. The manifestation is that when we have (symacrolet ((x 1)) (labels () x)), the x fails to expand; it has been wrongly moved to the function bindings area of the macro environment. --- eval.c | 2 +- tests/011/macros-3.tl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index f8ecb236..aecc5a8e 100644 --- a/eval.c +++ b/eval.c @@ -2359,7 +2359,7 @@ static void builtin_reject_test(val op, val sym, val form, val def_kind) static val make_var_shadowing_env(val menv, val vars) { if (nilp(vars)) { - return menv; + return make_env(nil, nil, menv); } else if (atom(vars)) { return make_env(cons(cons(vars, special_s), nil), nil, menv); } else { diff --git a/tests/011/macros-3.tl b/tests/011/macros-3.tl index 9a595021..fda312da 100644 --- a/tests/011/macros-3.tl +++ b/tests/011/macros-3.tl @@ -18,3 +18,8 @@ (mtest s 1 s 2 s 3) + +(test (symacrolet ((a 42)) + (labels () + a)) + 42) -- cgit v1.2.3