summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-12-20 19:42:40 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-12-20 19:42:40 -0800
commit4356b0df29e5a156811e7388072e26799001e712 (patch)
tree5f1169b6a46eaa6bb9a0d3d6554a602c7f42e501
parentae79309b0b12092d2e3e10dfced0dcf1e9cc43ad (diff)
downloadtxr-4356b0df29e5a156811e7388072e26799001e712.tar.gz
txr-4356b0df29e5a156811e7388072e26799001e712.tar.bz2
txr-4356b0df29e5a156811e7388072e26799001e712.zip
match-case: bugfix in conversion to casequal.
* stdlib/match.tl (match-case-to-casequal): the (do inc dfl-cnt) action has a problem: it inserts an implicit extra parameter to the invocation of inc, which crashes the + addition due to that parameter being the matching @nil object. We don't need this entire case because it handles @nil, which also matches the following case for (sys:var ...), since @nil is (sys:var nil). That case ahs the same action of incrementing dfl-cnt. * tests/011/patmatch.tl: Test case added.
-rw-r--r--stdlib/match.tl2
-rw-r--r--tests/011/patmatch.tl3
2 files changed, 3 insertions, 2 deletions
diff --git a/stdlib/match.tl b/stdlib/match.tl
index a382a5e6..b717a1a4 100644
--- a/stdlib/match.tl
+++ b/stdlib/match.tl
@@ -710,8 +710,6 @@
(let ((dfl-cnt 0))
(if (and [all clauses
[chain car [orf [chain non-triv-pat-p not]
- [iff (op equal '@nil)
- (do inc dfl-cnt)]
(do if-match (@(eq 'sys:var) @nil) @1
(inc dfl-cnt))]]]
(< dfl-cnt 2)
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index 731a8796..3ccd180e 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -620,6 +620,9 @@
(match @(scan-all (b @x)) '(1 2 3 4 b 5 b 6 7 8) x) :error
(match @(scan-all (b @x . @nil)) '(1 2 3 4 b 5 b 6 7 8) x) (5 6))
+(test
+ (match-case 1 (@nil 2)) 2)
+
(compile-only
(eval-only
(with-compile-opts (nil unused)