1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00

Fix pattern variable extraction in match' with ..1'.

* module/ice-9/match.upstream.scm (match-extract-vars): Support `..1'.
This commit is contained in:
Ludovic Courtès 2010-09-27 23:52:10 +02:00
parent 1ffed5aa95
commit f2ee6341ba
2 changed files with 7 additions and 1 deletions

View file

@ -488,7 +488,7 @@
;; (match-extract-vars pattern continuation (ids ...) (new-vars ...))
(define-syntax match-extract-vars
(syntax-rules (_ ___ *** ? $ = quote quasiquote and or not get! set!)
(syntax-rules (_ ___ ..1 *** ? $ = quote quasiquote and or not get! set!)
((match-extract-vars (? pred . p) . x)
(match-extract-vars p . x))
((match-extract-vars ($ rec . p) . x)
@ -518,6 +518,7 @@
(match-extract-vars (p ...) . x))
((match-extract-vars _ (k ...) i v) (k ... v))
((match-extract-vars ___ (k ...) i v) (k ... v))
((match-extract-vars ..1 (k ...) i v) (k ... v))
((match-extract-vars *** (k ...) i v) (k ... v))
;; This is the main part, the only place where we might add a new
;; var if it's an unbound symbol.

View file

@ -77,6 +77,11 @@
(((and x (? symbol?)) ..1)
(equal? x '(a b c)))))
(pass-if "list ..1, nested"
(match '((1 2) (3 4))
(((x ..1) ..1)
(equal? x '((1 2) (3 4))))))
(pass-if "tree"
(let ((tree '(one (two 2) (three 3 (and 4 (and 5))))))
(match tree