typed-racket/typed-racket-test/succeed/pr390-variation-1.rkt
Ben Greenman fae58e140d add types for Immutable-HashTable, Mutable-HashTable, Weak-HashTable (#559)
The old 'HashTable' type is now the union of the other 3 hash types.

- all operations that used to work on 'HashTable's still work,
  but some now have more specific outputs
- `#hash` literals have type `ImmutableHash`
- `immutable?` and `hash-weak?` are filters
- `Mutable-` and `Weak-` hashes have corresponding `Top` types, `HashTableTop` is now a union
- the contact for `(U (Immutable-Hash K1 V1) (Mutable-Hash K2 V2))` is ONE `hash/c`

Minor notes:

- renamed internal identifiers containing 'Hashtable' to all use 'HashTable'
- add Racket guide/reference 'secref' functions
2017-06-26 18:00:19 -04:00

16 lines
470 B
Racket

#lang typed/racket
;; Reported by Matthew Eric Basset
;; https://groups.google.com/forum/#!searchin/racket-users/weirdness%7Csort:date/racket-users/g6UmwgZWtzE/1czSRfk2AgAJ
;; Works "as expected" on 6.5
(void
(ann (hash 'a 1 'b "cat") (HashTable Any Any)))
(define t* (hash 'a 1 'b "cat"))
;; These `ann` do not work on 6.5, should work because `hash` makes an immutable table
(void
(ann t* (HashTable Any Any))
(ann t* (HashTable Symbol (U String Integer))))