summaryrefslogtreecommitdiffstats
path: root/tests/011
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-11 07:48:12 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-11 07:48:12 -0700
commit54c276a0322a369079ba480aca98b4c0ddf70365 (patch)
treecc3d601a1da01eb92f1eac5fa7bac35b0710836c /tests/011
parentb1c7380ce9302c18edbce98e99ddb30fabd99abb (diff)
downloadtxr-54c276a0322a369079ba480aca98b4c0ddf70365.tar.gz
txr-54c276a0322a369079ba480aca98b4c0ddf70365.tar.bz2
txr-54c276a0322a369079ba480aca98b4c0ddf70365.zip
lambda-match: bug: over-strict match in variadic pattern.
* stdlib/match.tl (expand-lambda-match): A pattern that is shorter than the maximum number of arguments is augmented with a check ensuring that no fixed arguments are present beyond those that the pattern requires. However, this check must be omitted if the pattern is variadic, because those excess arguments match its tail pattern. * tests/011/patmatch.tl: Cases added.
Diffstat (limited to 'tests/011')
-rw-r--r--tests/011/patmatch.tl14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index 08bcd0f7..81cda935 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -247,6 +247,20 @@
((@x @y) :no-match)) 1 2 3]
:error)))
+(test
+ [(lambda-match
+ ((@a @b) (list a b))
+ ((@x . @y) (list x y)))
+ 1 2 3]
+ (1 (2 3)))
+
+(test
+ [(lambda-match
+ ((@a @b) (list a b))
+ (@x x))
+ 1 2 3]
+ (1 2 3))
+
(defun-match fib
((0) 1)
((1) 1)