summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-29 20:29:18 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-29 20:29:18 -0800
commit58c1642901889829eb55ceea2ae868dea848eab9 (patch)
treeddec96a3b39d9b11e72e15ee48d885259873b8d5 /share
parentab20526520a5458a40bdbf7b77af4cd5ef62c096 (diff)
downloadtxr-58c1642901889829eb55ceea2ae868dea848eab9.tar.gz
txr-58c1642901889829eb55ceea2ae868dea848eab9.tar.bz2
txr-58c1642901889829eb55ceea2ae868dea848eab9.zip
matcher: bugfix: @nil isn't trivial.
* share/txr/stdlib/match.tl (non-triv-pat-p): Extend sys:var match so (sys:var nil) is identified as trivial. * tests/011/patmatch.tl: Add broken test case fixed by this. This doesn't show up when @nil is used as the only match. It also doesn't show up if @nil is used in a vector or list in a mixture with other operators, because those other ones identify the overall list pattern as non-trivial. None of the occurrences of @nil in the existing test suite, like (@nil @nil @x) tickle the bug.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/match.tl2
1 files changed, 1 insertions, 1 deletions
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl
index 920ca14e..8c7a4fcf 100644
--- a/share/txr/stdlib/match.tl
+++ b/share/txr/stdlib/match.tl
@@ -540,7 +540,7 @@
(defun non-triv-pat-p (syntax)
(match-case syntax
((@(op eq 'sys:expr) (@(bindable) . @nil)) t)
- ((@(op eq 'sys:var) @(bindable) . @nil) t)
+ ((@(op eq 'sys:var) @(or @(bindable) nil) . @nil) t)
((@pat . @rest) (or (non-triv-pat-p pat)
(non-triv-pat-p rest)))
(#R(@from @to) (or (non-triv-pat-p from)