From 426579a1a05a9cd9b8858daa0fb8e04c3ab006ae Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" Date: Wed, 9 Feb 2022 09:30:22 +0000 Subject: 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. --- stdlib/match.tl | 7 +++++-- 1 file 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) -- cgit v1.2.3