diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-02-01 07:57:44 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-02-01 07:57:44 -0800 |
commit | 8b3280908b962ed5f0e15993a4b7006aa9acabd6 (patch) | |
tree | 879f72d49d634b46b6a4b760b2d8c2fa0f7fa226 | |
parent | bf9d6ebdedf2b97ef4a69c3cca488d9f9e7d4f37 (diff) | |
download | txr-8b3280908b962ed5f0e15993a4b7006aa9acabd6.tar.gz txr-8b3280908b962ed5f0e15993a4b7006aa9acabd6.tar.bz2 txr-8b3280908b962ed5f0e15993a4b7006aa9acabd6.zip |
matcher: bugfix: bad stray code in @[...] matcher.
* share/txr/stdlib/match.tl (compile-dwim-predicate-match): In
he one-argument case, there is stray code referencing
var-match.test-expr, which blows up. This is hit by exactly
the one example in the documentation that was not added
as a test case.
* tests/011/patmatch.tl: Add test case from doc.
-rw-r--r-- | share/txr/stdlib/match.tl | 3 | ||||
-rw-r--r-- | tests/011/patmatch.tl | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index 8518d68f..2c47ca2a 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -262,8 +262,7 @@ pat-match.guard-chain)))) (progn var-match.(add-guard-pre (new match-guard - guard-expr ^(and ,var-match.test-expr - [,fun ,obj-var]))) + guard-expr ^[,fun ,obj-var])) var-match))))) (defun compile-predicate-match (pred-expr obj-var var-list) diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index 7768e89b..347af4eb 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -161,6 +161,10 @@ (test (when-match (rcons @a @b) '(rcons 1 2) (list a b)) (1 2)) (test (let ((h #H(() (a 1) (b 2)))) + (when-match @[h x] 'a x)) + a) + +(test (let ((h #H(() (a 1) (b 2)))) (when-match @[h x y] 'a (list x y))) (a 1)) |