summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul A. Patience <paul@apatience.com>2022-02-09 09:30:22 +0000
committerKaz Kylheku <kaz@kylheku.com>2022-02-09 13:06:57 -0800
commit426579a1a05a9cd9b8858daa0fb8e04c3ab006ae (patch)
tree59affc34b798d55115488b1dd29c9339cc35b9bc
parent62eb7d8d48ec4a8b8e091d9b4c5ea167859b8413 (diff)
downloadtxr-426579a1a05a9cd9b8858daa0fb8e04c3ab006ae.tar.gz
txr-426579a1a05a9cd9b8858daa0fb8e04c3ab006ae.tar.bz2
txr-426579a1a05a9cd9b8858daa0fb8e04c3ab006ae.zip
matcher: fix `@{nil #/regex/}` throwing exception.
* stdlib/match.tl (expand-quasi-match): We cannot call m^$ with the @nil-bound rest of string when matching `@{nil #/regex/}`. Handle this case specially.
-rw-r--r--stdlib/match.tl7
1 files changed, 5 insertions, 2 deletions
diff --git a/stdlib/match.tl b/stdlib/match.tl
index cdc1415c..17870be2 100644
--- a/stdlib/match.tl
+++ b/stdlib/match.tl
@@ -958,8 +958,11 @@
(list ^@(with ,sym (sub-str ,str ,pos t))))
;; `@{var #/rx/}` (new binding)
(((@(eq 'sys:var) @sym (@(regexp @reg))))
- (list ^@(require @(with ,sym (sub-str ,str ,pos t))
- (m^$ ,reg ,sym))))
+ (if sym
+ (list ^@(require @(with ,sym (sub-str ,str ,pos t))
+ (m^$ ,reg ,sym)))
+ (list ^@(require @nil
+ (m^$ ,reg (sub-str ,str ,pos t))))))
;; `@{var #/rx/}@...` (new binding)
(((@(eq 'sys:var) @sym (@(regexp @reg))) . @rest)
(with-gensyms (len npos)