summaryrefslogtreecommitdiffstats
path: root/tests/011
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-22 00:17:46 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-22 00:17:46 -0800
commita5f90cf8a467ac8817ab3db5c9f8190b7a547d67 (patch)
tree872f4521ff5fbf3575075a2348ee532c39ab2590 /tests/011
parent16094ab126996e3963561b520ff22b405b56ca61 (diff)
downloadtxr-a5f90cf8a467ac8817ab3db5c9f8190b7a547d67.tar.gz
txr-a5f90cf8a467ac8817ab3db5c9f8190b7a547d67.tar.bz2
txr-a5f90cf8a467ac8817ab3db5c9f8190b7a547d67.zip
matcher: existing variables in @(all) now backref.
This commit fixes the inadequacy that all variables occurring in a pattern under @(all ...) or @(coll ...) are blindly collated into lists, ignoring the fact that they may be previously bound variables that must back-reference and not be colleced into lists (just like in the TXR Pattern language!) * share/txr/stdlib/match.tl (compile-loop-match): Calculate the subset of variables in the pattern that have been freshly bound. Only generate the collection gensyms for those variables and only collect and nreverse those variables. * tests/011/patmatch.tl: Some test cases that backreference into an @(all). * txr.1: Documented.
Diffstat (limited to 'tests/011')
-rw-r--r--tests/011/patmatch.tl4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index 11a6a933..2b1e26c8 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -54,6 +54,10 @@
(list a b))
((1 2 3) (a b c)))
+(test (when-match (@x @(all @x)) '(1 (1 1 1 1)) x) 1)
+
+(test (when-match (@x @(all @x)) '(1 (1 1 1 2)) x) nil)
+
(test (when-match @(some (x @a @b)) '((y 1 a) (x 2 b) (z 3 c))
(list a b))
(2 b))