From a1b37dbbff94493db56b600338b5b76ba2ae2313 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 17 Jul 2023 20:19:17 -0700 Subject: bug: compiled code keeps seeing var clobbered by symacro. * eval.c (op_defsymacro, rt_defsymacro): We must call vm_invalidate_binding so the VM forgets a cached binding for this variable. * tests/019/redef.tl: Test added. --- eval.c | 2 ++ tests/019/redef.tl | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/eval.c b/eval.c index 107f623d..f82747b2 100644 --- a/eval.c +++ b/eval.c @@ -2162,6 +2162,7 @@ static val op_defsymacro(val form, val env) if (!opt_compat || opt_compat > 143) remhash(special, sym); sethash(top_smb, sym, second(args)); + vm_invalidate_binding(sym); return sym; } @@ -2171,6 +2172,7 @@ static val rt_defsymacro(val sym, val def) remhash(top_vb, sym); remhash(special, sym); sethash(top_smb, sym, def); + vm_invalidate_binding(sym); return sym; } diff --git a/tests/019/redef.tl b/tests/019/redef.tl index 036fb8c9..943b5c3a 100644 --- a/tests/019/redef.tl +++ b/tests/019/redef.tl @@ -17,3 +17,7 @@ (defparml foov :barv) (test (bar) (:bar :barv)) + +(defsymacro foov 42) + +(test (bar) :error) -- cgit v1.2.3