From 258d9b8e2f53936ff166c069ca0ab267ed77f602 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Sun, 1 Dec 2013 11:25:52 -0800 Subject: [PATCH] Add #f as a special case for hash-ref, fix hash-ref!. Closes PR 14158. Merge to 6.0. --- .../typed-racket-lib/typed-racket/base-env/base-env.rkt | 6 +++--- .../tests/typed-racket/unit-tests/typecheck-tests.rkt | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/base-env.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/base-env.rkt index 2f38508e49..0e62c2aa37 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/base-env.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/base-env.rkt @@ -713,12 +713,12 @@ [hash-set! (-poly (a b) ((-HT a b) a b . -> . -Void))] [hash-ref (-poly (a b c) (cl-> [((-HT a b) a) b] + [((-HT a b) a (-val #f)) (-opt b)] [((-HT a b) a (-> c)) (Un b c)] [(-HashTop a) Univ] + [(-HashTop a (-val #f)) Univ] [(-HashTop a (-> c)) Univ]))] -[hash-ref! (-poly (a b) - (cl-> [((-HT a b) a b) b] - [((-HT a b) a (-> b)) b]))] +[hash-ref! (-poly (a b) (-> (-HT a b) a (-> b) b))] [hash-has-key? (-HashTop Univ . -> . B)] [hash-update! (-poly (a b) (cl-> [((-HT a b) a (-> b b)) -Void] diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt index ebc14a2227..a3925076b3 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt @@ -1845,6 +1845,12 @@ (define x 3) (if ((negate pos?) x) x -5)) #:ret (ret -NonPosReal (-FS -top -bot))] + + [tc-err + (hash-ref! (ann (make-hash) (HashTable #f (-> #t))) #f (lambda () #t))] + [tc-e + (hash-ref (ann (make-hash) (HashTable #f #t)) #f #f) + -Boolean] ) (test-suite "tc-literal tests"