summaryrefslogtreecommitdiffstats
path: root/stdlib
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
commita793f0a88cfd08167d7717f40df25bc5eaf0d7ba (patch)
tree59affc34b798d55115488b1dd29c9339cc35b9bc /stdlib
parent1c26268239530d58baebfbb43dcdc39b4bf5982b (diff)
downloadtxr-a793f0a88cfd08167d7717f40df25bc5eaf0d7ba.tar.gz
txr-a793f0a88cfd08167d7717f40df25bc5eaf0d7ba.tar.bz2
txr-a793f0a88cfd08167d7717f40df25bc5eaf0d7ba.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.
Diffstat (limited to 'stdlib')
-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)