From 58c1642901889829eb55ceea2ae868dea848eab9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 29 Jan 2021 20:29:18 -0800 Subject: 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. --- tests/011/patmatch.tl | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/011') diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index 6a9c6f18..7768e89b 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -9,6 +9,7 @@ (yes no)) (test (when-match @a 42 (list a)) (42)) +(test (when-match (@nil) '(1) 'yes) yes) (test (when-match (@a @b @c) '(1 2 3) (list c b a)) (3 2 1)) (test (if-match (@a @b @c . @d) '(1 2 3 . 4) (list d c b a)) (4 3 2 1)) -- cgit v1.2.3