Skip to content

Commit efc3545

Browse files
authored
rule out NaN in true props in types of positive? and negative? (#1227)
closes #750
1 parent 0cf01d2 commit efc3545

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,8 @@
798798
[fixnum? (make-pred-ty -Fixnum)]
799799
[fixnum-for-every-system? (asym-pred Univ B (-PS (-is-type 0 -Fixnum) -tt))]
800800
[index? (make-pred-ty -Index)]
801-
[positive? (-> -Real B : (-PS (-is-type 0 -PosReal) (-is-type 0 -NonPosReal)))]
802-
[negative? (-> -Real B : (-PS (-is-type 0 -NegReal) (-is-type 0 -NonNegReal)))]
801+
[positive? (-> -Real B : (-PS (-is-type 0 -PosRealNoNan) (-is-type 0 -NonPosReal)))]
802+
[negative? (-> -Real B : (-PS (-is-type 0 -NegRealNoNan) (-is-type 0 -NonNegReal)))]
803803
[exact-positive-integer? (make-pred-ty -Pos)]
804804
[exact-nonnegative-integer? (make-pred-ty -Nat)]
805805

typed-racket-test/unit-tests/typecheck-tests.rkt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,14 @@
541541
1.0
542542
x))
543543
-NonNegFlonum)
544+
(tc-e/t (let ([a : (U One Float-Nan) 1])
545+
(if (positive? a) a
546+
1))
547+
-One)
548+
(tc-e/t (let ([a : (U Negative-Fixnum Float-Nan) -1])
549+
(if (negative? a) a
550+
-1))
551+
-NegFixnum)
544552
(tc-e (exact->inexact (expt 10 (/ -120.0 20))) ; from rsound
545553
-NonNegInexactReal)
546554
(tc-e (flexpt 0.5 0.3) -NonNegFlonum)

0 commit comments

Comments
 (0)