diff --git a/typed-racket-lib/typed-racket/types/generalize.rkt b/typed-racket-lib/typed-racket/types/generalize.rkt index f1f62c42..cab68b18 100644 --- a/typed-racket-lib/typed-racket/types/generalize.rkt +++ b/typed-racket-lib/typed-racket/types/generalize.rkt @@ -31,6 +31,9 @@ [(? (lambda (t) (subtype t -Char))) -Char] [(? (lambda (t) (subtype t -ExtFlonum))) -ExtFlonum] [(Listof: _) t*] + [(Immutable-HashTable: k v) (-HT k v)] + [(Mutable-HashTable: k v) (-HT k v)] + [(Weak-HashTable: k v) (-HT k v)] [(Pair: t1 (== -Null)) (-lst t1)] [(MPair: t1 (== -Null)) (-mlst t1)] [(or (Pair: t1 t2) (MPair: t1 t2)) diff --git a/typed-racket-test/unit-tests/typecheck-tests.rkt b/typed-racket-test/unit-tests/typecheck-tests.rkt index 3589580f..7991da67 100644 --- a/typed-racket-test/unit-tests/typecheck-tests.rkt +++ b/typed-racket-test/unit-tests/typecheck-tests.rkt @@ -3970,6 +3970,51 @@ [tc-e (let ([a (inst cons Integer Integer)]) (cons #f #f)) (-pair -False -False)] + ;; TR github issue 573 + ;; make sure immutable hash tables generalize to just hash + [tc-e (let () + (define h1 (hash)) + + (: hfun (-> (HashTable Any Any) (HashTable Any Any))) + (define (hfun h) h) + + (define h2 + (for/fold : (HashTable Any Any) + ([h h1]) + ([_ (in-range 3)]) + (hfun h))) + (void)) + -Void] + ;; TR github issue 573 + ;; make sure mutable hash tables generalize to just hash + [tc-e (let () + (define h1 (make-hash '())) + + (: hfun (-> (HashTable Any Any) (HashTable Any Any))) + (define (hfun h) h) + + (define h2 + (for/fold : (HashTable Any Any) + ([h h1]) + ([_ (in-range 3)]) + (hfun h))) + (void)) + -Void] + ;; TR github issue 573 + ;; make sure weak hash tables generalize to just hash + [tc-e (let () + (define h1 (make-weak-hash '())) + + (: hfun (-> (HashTable Any Any) (HashTable Any Any))) + (define (hfun h) h) + + (define h2 + (for/fold : (HashTable Any Any) + ([h h1]) + ([_ (in-range 3)]) + (hfun h))) + (void)) + -Void] ) (test-suite