diff options
author | Paul A. Patience <paul@apatience.com> | 2022-02-09 09:30:22 +0000 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-02-09 13:06:57 -0800 |
commit | a793f0a88cfd08167d7717f40df25bc5eaf0d7ba (patch) | |
tree | 59affc34b798d55115488b1dd29c9339cc35b9bc | |
parent | 1c26268239530d58baebfbb43dcdc39b4bf5982b (diff) | |
download | txr-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.
-rw-r--r-- | stdlib/match.tl | 7 |
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) |