From 718718b657cc07dab9b3f3e74106b4ba4d0dadaf Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 27 Jul 2023 20:24:33 -0700 Subject: match: bug: lexical symbol macros neglected When a pattern variable match like @foo references a global symbol macro, that's treated as an existing expression to match, and not a new binding. However, local symbol macros are not treated this way; they are invisible to variable patterns. That is an unintended inconsistency. * stdlib/match.tl (var-list exists): Use lexical-binding-kind rather than lexical-var-p. This returns true for lexical symbol macros also. * tests/011/patmatch.tl: New test cases. * txr.1: Documentation revised to clarify that both global and local symbol macros are considered to be existing variable bindings by pattern matching. --- tests/011/patmatch.tl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/011') diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index 2e05d59f..bb67e32e 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -583,6 +583,25 @@ (match-cond (`@x-24` `42-@y`))) "42-24") +(mtest + (symacrolet ((x 3)) + (match @x 4 x)) :error + (symacrolet ((x 3)) + (match @x 3 x)) 3 + (let ((x 3)) + (match @x 4 x)) :error + (let ((x 3)) + (match @x 3 x)) 3) + +(defvar dv :dv) +(defsymacro gs :gs) + +(mtest + (match @dv 0 dv) :error + (match @dv :dv dv) :dv + (match @gs 0 gs) :error + (match @gs :gs gs) :gs) + (compile-only (eval-only (with-compile-opts (nil unused) -- cgit v1.2.3