improve hash/c error message when non-flat-key applied to non-equal?-hash
This commit is contained in:
parent
cfa9918ac5
commit
26f65f13f7
|
@ -23,6 +23,9 @@
|
|||
(and/c hash? hash-weak? (hash/c/check-key k v #:immutable #f)))
|
||||
|
||||
(define (hash/c/check-key k v #:immutable [immutable 'dont-care])
|
||||
;; TODO if (flat-contract? k), then make a contract that produces a "good"
|
||||
;; error message given a hashtable that is not a `hash-equal?`
|
||||
(hash/c k v #:immutable immutable))
|
||||
(if (flat-contract? k)
|
||||
(hash/c k v #:immutable immutable)
|
||||
(and/c (flat-named-contract
|
||||
"hash-equal? (because the key contract is not a flat contract)"
|
||||
hash-equal?)
|
||||
(hash/c k v #:immutable immutable))))
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
(require 't rackunit)
|
||||
|
||||
(define err-regexp #rx"expected equal\\?-based hash")
|
||||
(define err-regexp #rx"hash-equal\\?.*key contract is not a flat contract")
|
||||
|
||||
(check-exn err-regexp
|
||||
(λ () (give-me-a-hash (hasheqv))))
|
||||
|
|
Loading…
Reference in New Issue
Block a user