diff --git a/pkgs/racket-test/tests/racket/contract/stronger.rkt b/pkgs/racket-test/tests/racket/contract/stronger.rkt index 9004535ba1..ef725a0b8e 100644 --- a/pkgs/racket-test/tests/racket/contract/stronger.rkt +++ b/pkgs/racket-test/tests/racket/contract/stronger.rkt @@ -150,6 +150,8 @@ (or/c (-> string?) (-> integer? integer?) integer?) (or/c (-> integer? integer?) integer?)) + (ctest #t contract-stronger? (list/c) '()) + (ctest #t contract-stronger? (list/c) '()) (ctest #t contract-stronger? (cons/c boolean? integer?) (cons/c boolean? integer?)) (ctest #f contract-stronger? (cons/c boolean? integer?) (cons/c integer? boolean?)) (ctest #t contract-stronger? (cons/c number? (listof number?)) (non-empty-listof number?)) diff --git a/racket/collects/racket/contract/private/guts.rkt b/racket/collects/racket/contract/private/guts.rkt index 10b3b6abcb..b59d57cb2a 100644 --- a/racket/collects/racket/contract/private/guts.rkt +++ b/racket/collects/racket/contract/private/guts.rkt @@ -52,7 +52,7 @@ contract-custom-write-property-proc (rename-out [contract-custom-write-property-proc custom-write-property-proc]) - set-listof-any-and-cons/c-anyany!) + set-some-basic-contracts!) (define (contract-custom-write-property-proc stct port display?) (write-string "#<" port) @@ -220,9 +220,11 @@ ;; bang it in here and use it only after it's been banged in. (define listof-any #f) (define consc-anyany #f) -(define (set-listof-any-and-cons/c-anyany! l p) +(define list/c-empty #f) +(define (set-some-basic-contracts! l p mt) (set! listof-any l) - (set! consc-anyany p)) + (set! consc-anyany p) + (set! list/c-empty mt)) (define (coerce-contract/f x [name name-default]) (define (coerce-simple-value x) @@ -239,7 +241,8 @@ x #f (memq x the-known-good-contracts))])] - [(or (symbol? x) (boolean? x) (char? x) (null? x) (keyword? x)) + [(null? x) list/c-empty] + [(or (symbol? x) (boolean? x) (char? x) (keyword? x)) (make-eq-contract x (if (name-default? name) (if (or (null? x) diff --git a/racket/collects/racket/contract/private/misc.rkt b/racket/collects/racket/contract/private/misc.rkt index 0d0c33248e..3835b3a0fe 100644 --- a/racket/collects/racket/contract/private/misc.rkt +++ b/racket/collects/racket/contract/private/misc.rkt @@ -1135,8 +1135,11 @@ (higher-order-list/c ctc-args)])) (define (list/c-name-proc c) - (apply build-compound-type-name - 'list/c (generic-list/c-args c))) + (define args (generic-list/c-args c)) + (cond + [(null? args) ''()] + [else (apply build-compound-type-name 'list/c args)])) + (define ((list/c-first-order c) x) (and (list? x) (= (length x) (length (generic-list/c-args c))) @@ -2108,5 +2111,8 @@ [else "th"]))) ;; this is a hack to work around cyclic linking issues; -;; see definition of set-listof-any-and-cons/c-anyany! -(set-listof-any-and-cons/c-anyany! (listof any/c) (cons/c any/c any/c)) +;; see definition of set-some-basic-contracts! +(set-some-basic-contracts! + (listof any/c) + (cons/c any/c any/c) + (list/c))