diff --git a/collects/scheme/match/parse-helper.ss b/collects/scheme/match/parse-helper.ss index acc3e8c6b2..43ce9e91d8 100644 --- a/collects/scheme/match/parse-helper.ss +++ b/collects/scheme/match/parse-helper.ss @@ -177,9 +177,9 @@ #f)) ;; (listof pat) syntax -> void +;; ps is never null ;; check that all the ps bind the same set of variables -(define (all-vars ps stx) - (when (null? ps) (error 'bad)) +(define (all-vars ps stx) (let* ([first-vars (bound-vars (car ps))] [l (length ps)] [ht (make-free-identifier-mapping)]) diff --git a/collects/scheme/match/parse-legacy.ss b/collects/scheme/match/parse-legacy.ss index c499161f23..b8abf16dc1 100644 --- a/collects/scheme/match/parse-legacy.ss +++ b/collects/scheme/match/parse-legacy.ss @@ -25,8 +25,10 @@ "This expander only works with the standard match syntax")] [(and p ...) (make-And (map parse (syntax->list #'(p ...))))] - [(or p ...) - (let ([ps (map parse (syntax->list #'(p ...)))]) + [(or) + (make-Not (make-Dummy stx))] + [(or p ps ...) + (let ([ps (map parse (syntax->list #'(p ps ...)))]) (all-vars ps stx) (make-Or ps))] [(not p ...) diff --git a/collects/scheme/match/parse.ss b/collects/scheme/match/parse.ss index 468d0d9366..ce58a12fad 100644 --- a/collects/scheme/match/parse.ss +++ b/collects/scheme/match/parse.ss @@ -38,8 +38,10 @@ (make-Var #'v)] [(and p ...) (make-And (map parse (syntax->list #'(p ...))))] - [(or p ...) - (let ([ps (map parse (syntax->list #'(p ...)))]) + [(or) + (make-Not (make-Dummy stx))] + [(or p ps ...) + (let ([ps (map parse (syntax->list #'(p ps ...)))]) (all-vars ps stx) (make-Or ps))] [(not p ...) diff --git a/collects/tests/match/examples.ss b/collects/tests/match/examples.ss index 679f6c09e5..d386c39b93 100644 --- a/collects/tests/match/examples.ss +++ b/collects/tests/match/examples.ss @@ -598,4 +598,9 @@ [(? number?) (z)])) (lambda _ 12))) + + (comp 4 + (match 3 + [(or) 1] + [_ 4])) ))