From 2791f89cd2b455e1182f29b6c14d38b3162ae3a7 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. original commit: 258d9b8e2f53936ff166c069ca0ab267ed77f602 --- .../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 2f38508e..0e62c2aa 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 ebc14a22..a3925076 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"