Fix PR 10806.

svn: r18464
This commit is contained in:
Sam Tobin-Hochstadt 2010-03-04 13:45:25 +00:00
parent 82af25486e
commit 80fcee2577
2 changed files with 16 additions and 2 deletions

View File

@ -87,13 +87,17 @@
(cond [(equal? super #t) '()] ;; no super type exists (cond [(equal? super #t) '()] ;; no super type exists
[(equal? super #f) '()] ;; super type is unknown [(equal? super #f) '()] ;; super type is unknown
[else (cons super (get-lineage super))]))) [else (cons super (get-lineage super))])))
(unless pred
(raise-syntax-error 'match (format "structure ~a does not have an associated predicate"
(syntax->datum struct-name))
stx struct-name))
(let* (;; the accessors come in reverse order (let* (;; the accessors come in reverse order
[acc (reverse acc)] [acc (reverse acc)]
;; remove the first element, if it's #f ;; remove the first element, if it's #f
[acc (cond [(null? acc) acc] [acc (cond [(null? acc) acc]
[(not (car acc)) (cdr acc)] [(not (car acc)) (cdr acc)]
[else acc])]) [else acc])])
(make-Struct id (make-Struct pred
(syntax-property (syntax-property
pred pred
'disappeared-use (list struct-name)) 'disappeared-use (list struct-name))

View File

@ -2,7 +2,7 @@
(require scheme/match (require scheme/match
scheme/mpair scheme/mpair
scheme/control scheme/control scheme/foreign
(for-syntax scheme/base) (for-syntax scheme/base)
(prefix-in m: mzlib/match) (prefix-in m: mzlib/match)
(only-in srfi/13 string-contains) (only-in srfi/13 string-contains)
@ -623,5 +623,15 @@
[`#s((bar foo 3) ,x ,y ,z ,w) [`#s((bar foo 3) ,x ,y ,z ,w)
(list x y z)]) (list x y z)])
)) ))
(comp "Gotcha!"
(let ()
(define-cstruct _pose
([x _double*]
[y _double*]
[a _double*]))
(match (make-pose 1 2 3)
[(struct pose (x y a)) "Gotcha!"]
[else "Epic fail!"])))
)) ))