mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
paper around `match' bug
* module/ice-9/match.scm (match): Always introduce a lexical binding, to avoid http://debbugs.gnu.org/9567. Real fix ongoing. Patch and original report by Stefan Israelsson Tampe. * test-suite/tests/match.test: Add test.
This commit is contained in:
parent
250991010f
commit
8f6dfb9ad2
2 changed files with 30 additions and 0 deletions
|
@ -57,3 +57,21 @@
|
|||
;; Note: Make sure to update `match.test.upstream' when updating this
|
||||
;; file.
|
||||
(include-from-path "ice-9/match.upstream.scm")
|
||||
|
||||
(define-syntax match
|
||||
(syntax-rules ()
|
||||
((match)
|
||||
(match-syntax-error "missing match expression"))
|
||||
((match atom)
|
||||
(match-syntax-error "no match clauses"))
|
||||
((match (app ...) (pat . body) ...)
|
||||
(let ((v (app ...)))
|
||||
(match-next v ((app ...) (set! (app ...))) (pat . body) ...)))
|
||||
((match #(vec ...) (pat . body) ...)
|
||||
(let ((v #(vec ...)))
|
||||
(match-next v (v (set! v)) (pat . body) ...)))
|
||||
((match atom (pat . body) ...)
|
||||
(let ((v atom))
|
||||
(match-next v (atom (set! atom)) (pat . body) ...)))
|
||||
))
|
||||
|
||||
|
|
|
@ -102,6 +102,18 @@
|
|||
(('one ('two x) ('three y ('and z '(and 5))))
|
||||
(equal? (list x y z) '(2 3 4))))))
|
||||
|
||||
(pass-if "and, unique names"
|
||||
(let ((tree '(1 2)))
|
||||
(match tree
|
||||
((and (a 2) (1 b))
|
||||
(equal? 3 (+ a b))))))
|
||||
|
||||
(pass-if "and, same names"
|
||||
(let ((a '(1 2)))
|
||||
(match a
|
||||
((and (a 2) (1 b))
|
||||
(equal? 3 (+ a b))))))
|
||||
|
||||
(with-test-prefix "records"
|
||||
|
||||
(pass-if "all slots, bind"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue