From 625a22dbae0b10eb03cbbbef0fb3a1457f916d7a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 21 Jan 2021 07:23:27 -0800 Subject: matcher: fix broken @(let @a @(some @a)) test case. This is caused by the way the loop match compiler moves the matching logic into a guard, which causes a re-ordering of the variable assignments which interferes with backreferencing when @(some) is embedded into a @(let), and probably other situations. The issues is that the backreferencing equal tests can be reordered to occur before the assignment which sets the intial value of the backreferenced variable: cart before the horse kind of thing. * share/txr/stdlib/match.tl (compile-loop-match): Do not add the submatch into the guard sequence. Thus guard1's vars and var-exprs, move into into the main compiled-match, and guard1's guard-expr moves into guard0. Thus guard1 disappears, guard0 becomes guard. * tests/011/patmatch.tl: New test case that is also fixed, and which was not fixed by a different approach to the problem that I scrapped. --- tests/011/patmatch.tl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/011') diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index 7d0482b2..84d59381 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -88,3 +88,5 @@ (set *print-circle* t) (test (when-match @(let a @(some @a)) '#1=(1 2 #1# 3) :yes) :yes) + +(test (when-match (@a @(let a @(some @a))) '(#1=(1 2 #1# 3) #1#) :yes) :yes) -- cgit v1.2.3