diff --git a/pkgs/racket-pkgs/racket-test/tests/racket/contract/stronger.rkt b/pkgs/racket-pkgs/racket-test/tests/racket/contract/stronger.rkt index acacf47d6d..89aa48794a 100644 --- a/pkgs/racket-pkgs/racket-test/tests/racket/contract/stronger.rkt +++ b/pkgs/racket-pkgs/racket-test/tests/racket/contract/stronger.rkt @@ -43,6 +43,13 @@ (let ([c (contract-eval '(->i () () any))]) (test #t (contract-eval 'contract-stronger?) c c)) + (ctest #f contract-stronger? + (->* () #:pre (zero? (random 10)) any) + (->* () #:pre (zero? (random 10)) any)) + (ctest #f contract-stronger? + (->* () integer? #:post (zero? (random 10))) + (->* () integer? #:post (zero? (random 10)))) + (ctest #t contract-stronger? (or/c null? any/c) (or/c null? any/c)) (ctest #f contract-stronger? (or/c null? any/c) (or/c boolean? any/c)) (ctest #t contract-stronger? (or/c null? boolean?) (or/c null? boolean?)) diff --git a/racket/lib/collects/racket/contract/private/arrow.rkt b/racket/lib/collects/racket/contract/private/arrow.rkt index 12df77be0f..90f61b756a 100644 --- a/racket/lib/collects/racket/contract/private/arrow.rkt +++ b/racket/lib/collects/racket/contract/private/arrow.rkt @@ -571,7 +571,15 @@ (andmap contract-stronger? (base->-optional-kwds/c that) (base->-optional-kwds/c this)) (= (length (base->-rngs/c that)) (length (base->-rngs/c this))) - (andmap contract-stronger? (base->-rngs/c this) (base->-rngs/c that)))) + (andmap contract-stronger? (base->-rngs/c this) (base->-rngs/c that)) + + ;; these procs might be based on state; only + ;; allow stronger to be true when #:pre and + ;; #:post aren't specified at all + (not (base->-pre this)) + (not (base->-pre that)) + (not (base->-post this)) + (not (base->-post that)))) (define (->-generate ctc) (let ([doms-l (length (base->-doms/c ctc))])