diff --git a/collects/tests/typed-racket/unit-tests/typecheck-tests.rkt b/collects/tests/typed-racket/unit-tests/typecheck-tests.rkt index dc244ff243..5d6a4ada3c 100644 --- a/collects/tests/typed-racket/unit-tests/typecheck-tests.rkt +++ b/collects/tests/typed-racket/unit-tests/typecheck-tests.rkt @@ -266,6 +266,9 @@ (when (boolean? x) #t)) -Void] + [tc-e (integer-bytes->integer '#"abcd" #t) -Nat] + [tc-e (integer-bytes->integer '#"abcd" #f) -Int] + [tc-e/t (let: ([x : Any 3]) (if (list? x) (begin (car x) 1) diff --git a/collects/typed-racket/base-env/base-env-indexing-abs.rkt b/collects/typed-racket/base-env/base-env-indexing-abs.rkt index ac1c76c32d..23c12c1e9f 100644 --- a/collects/typed-racket/base-env/base-env-indexing-abs.rkt +++ b/collects/typed-racket/base-env/base-env-indexing-abs.rkt @@ -303,7 +303,14 @@ [bytes-utf-8-index (-Bytes [index-type (Un (-val #f) -Char) index-type index-type] . ->opt . -Index)] [integer->integer-bytes (-Integer index-type Univ [Univ -Bytes index-type] . ->opt . -Bytes)] - [integer-bytes->integer (-Bytes Univ [Univ index-type index-type] . ->opt . -Integer)] + [integer-bytes->integer + (cl->* + ;; Any truthy value (not only #t) would work here. + ;; We can define a truthy type (without difference types (- Univ #f)) + ;; by unioning everything (including StructTop and co). + ;; We should do this at some point. + (-Bytes (-val #t) [Univ index-type index-type] . ->opt . -Nat) + (-Bytes Univ [Univ index-type index-type] . ->opt . -Integer))] [peek-char (cl->* [->opt [-Input-Port index-type] (Un -Char (-val eof))])] diff --git a/collects/typed-racket/base-env/base-env-numeric.rkt b/collects/typed-racket/base-env/base-env-numeric.rkt index cb25ff614b..e2ab30be81 100644 --- a/collects/typed-racket/base-env/base-env-numeric.rkt +++ b/collects/typed-racket/base-env/base-env-numeric.rkt @@ -1352,9 +1352,11 @@ (-NonPosInt -Int . -> . (-values (list -Int -NonPosInt))) (-Int -Int . -> . (-values (list -Int -Int))))] -[arithmetic-shift (cl->* (-Zero (Un -NegFixnum -Zero) . -> . -Zero) - (-NonNegFixnum (Un -NegFixnum -Zero) . -> . -NonNegFixnum) - (-Fixnum (Un -NegFixnum -Zero) . -> . -Fixnum) +[arithmetic-shift (cl->* (-Zero -NonPosInt . -> . -Zero) + (-Byte -NonPosInt . -> . -Byte) + (-Index -NonPosInt . -> . -Index) + (-NonNegFixnum -NonPosInt . -> . -NonNegFixnum) + (-Fixnum -NonPosInt . -> . -Fixnum) (-Nat -Int . -> . -Nat) (-Int -Int . -> . -Int))]