diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/filter-ops.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/filter-ops.rkt index 7147733a..41b3f37b 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/filter-ops.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/filter-ops.rkt @@ -187,9 +187,12 @@ [(cons (AndFilter: fs*) fs) (loop fs (append fs* results))] [(cons f fs) (loop fs (cons f results))]))) ;; Move all the type filters up front as they are the stronger props - (define-values (f-args other-args) - (partition TypeFilter? (flatten-ands (remove-duplicates args eq? #:key Rep-seq)))) - (let loop ([fs (append f-args other-args)] [result null]) + (define-values (filters other-args) + (partition (λ (f) (or (TypeFilter? f) (NotTypeFilter? f))) + (flatten-ands (remove-duplicates args eq? #:key Rep-seq)))) + (define-values (type-filters not-type-filters) + (partition TypeFilter? filters)) + (let loop ([fs (append type-filters not-type-filters other-args)] [result null]) (if (null? fs) (match result [(list) -top] diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt index 4772e780..051a874d 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt @@ -131,5 +131,18 @@ (-filter -Symbol #'x)) (check-equal? (-and (-not-filter (-val #f) #'x) (-filter -Symbol #'x)) - (-filter -Symbol #'x))) + (-filter -Symbol #'x)) + + (check-equal? + (-and (-filter (-val #f) #'y) + (-or (-filter (-val #f) #'y) + (-filter (-val #f) #'x))) + (-filter (-val #f) #'y)) + + (check-equal? + (-and (-not-filter (-val #f) #'y) + (-or (-not-filter (-val #f) #'y) + (-not-filter (-val #f) #'x))) + (-not-filter (-val #f) #'y))) + ))