diff --git a/typed-racket-lib/typed-racket/private/type-contract.rkt b/typed-racket-lib/typed-racket/private/type-contract.rkt index 54e78552..ba2e50dd 100644 --- a/typed-racket-lib/typed-racket/private/type-contract.rkt +++ b/typed-racket-lib/typed-racket/private/type-contract.rkt @@ -627,6 +627,9 @@ (syntax/sc (t->sc t))] [(Value: v) (if (and (c:flat-contract? v) + ;; numbers used as contracts compare with =, but TR + ;; requires an equal? check + (not (number? v)) ;; regexps don't match themselves when used as contracts (not (regexp? v))) (flat/sc #`(quote #,v)) diff --git a/typed-racket-test/unit-tests/contract-tests.rkt b/typed-racket-test/unit-tests/contract-tests.rkt index a040645e..ba0267c3 100644 --- a/typed-racket-test/unit-tests/contract-tests.rkt +++ b/typed-racket-test/unit-tests/contract-tests.rkt @@ -368,6 +368,18 @@ #:untyped #:msg #rx"that accepts 1 non-keyword") + ;; Value types with numbers shouldn't be checked with = + (t-int/fail (make-Value 3.0) + values + 3 + #:untyped + #:msg #rx"promised: 3.0") + (t-int/fail (make-Value 3) + values + 3.0 + #:untyped + #:msg #rx"promised: 3") + ;; intersection types (t (-unsafe-intersect (-seq -Symbol) (-pair -Symbol (-lst -Symbol)))) (t/fail (-unsafe-intersect (-Number . -> . -Number) (-String . -> . -String))