summaryrefslogtreecommitdiffstats
path: root/tests/011
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-02-08 07:06:30 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-02-08 07:06:30 -0800
commitc8d581648431d6df4cc1db9e87a1ad1306aeddb8 (patch)
tree52d1630fe483601db7bce3b8dd9ddcb097974625 /tests/011
parentde6ced80888ed410aa96729879921b5dc5066a51 (diff)
downloadtxr-c8d581648431d6df4cc1db9e87a1ad1306aeddb8.tar.gz
txr-c8d581648431d6df4cc1db9e87a1ad1306aeddb8.tar.bz2
txr-c8d581648431d6df4cc1db9e87a1ad1306aeddb8.zip
matcher: fix backreferencing in predicate.
* share/txr/stdlib/match.tl (compile-predicate-match): Always allocate res-var as a gensym; do not use resvar. Otherwise we will freshly bind resvar as a local, failing to back-reference. * tests/011/patmatch.tl: Add test cases, the second of which fails before this change.
Diffstat (limited to 'tests/011')
-rw-r--r--tests/011/patmatch.tl6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index a616b9d2..f49b115d 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -94,6 +94,12 @@
(t (1 2 3)))
(test (when-match @(@x (< . @sym)) '(3 2 1) (list x sym))
nil)
+(test (let ((x t))
+ (when-match @(@x (< . @sym)) '(1 2 3) (list x sym)))
+ (t (1 2 3)))
+(test (let ((x nil))
+ (when-match @(@x (< . @sym)) '(1 2 3) (list x sym)))
+ nil)
(test (if-match (@(or @a) @a) '(1 2) a :no) :no)
(test (if-match (@(and @a) @a) '(1 2) a :no) :no)