Fix typechecking of single flonum literals, now that they are enabled by default.

original commit: 0f0a2625c6765a48e6aeb41230d2e6d9225f9c9e
This commit is contained in:
Vincent St-Amour 2011-01-19 17:49:50 -05:00
parent c0970cc647
commit 97d8f2613c

View File

@ -51,26 +51,19 @@
[(~var i (3d (conjoin flonum? positive?))) -PosFlonum]
[(~var i (3d (conjoin flonum? negative?))) -NegFlonum]
[(~var i (3d flonum?)) -Flonum] ; for nan
;; Single flonum literals can't be assigned a type normally.
;; Since single flonums can't live in a zo, the compilation process
;; promotes them silently to plain flonums. Thus, a single float
;; literal can, at runtime turn into either a single flonum (if the
;; program is not compiled) or a plain flonum (if it is).
;; That means that if we see a single flonum literal, we have to
;; give it an Inexact-Real type, which covers both cases.
[(~var i (3d (lambda (x) (eq? x 0.0f0)))) -InexactRealPosZero]
[(~var i (3d (lambda (x) (eq? x -0.0f0)))) -InexactRealNegZero]
[(~var i (3d (conjoin inexact-real? positive?))) -PosInexactReal]
[(~var i (3d (conjoin inexact-real? negative?))) -NegInexactReal]
[(~var i (3d inexact-real?)) -InexactReal] ; for nan
[(~var i (3d (lambda (x) (eq? x 0.0f0)))) -SingleFlonumPosZero]
[(~var i (3d (lambda (x) (eq? x -0.0f0)))) -SingleFlonumNegZero]
[(~var i (3d (conjoin single-flonum? positive?))) -PosSingleFlonum]
[(~var i (3d (conjoin single-flonum? negative?))) -NegSingleFlonum]
[(~var i (3d single-flonum?)) -SingleFlonum] ; for nan
[(~var i (3d inexact-real?)) -InexactReal] ; catch-all, just in case
[(~var i (3d real?)) -Real] ; catch-all, just in case
;; a complex number can't have a float imaginary part and an exact real part
[(~var i (3d (conjoin number? (lambda (x) (and (flonum? (imag-part x))
(flonum? (real-part x)))))))
-FloatComplex]
;; same issue as single flonums
[(~var i (3d (conjoin number? (lambda (x) (and (inexact-real? (imag-part x))
(inexact-real? (real-part x)))))))
[(~var i (3d (conjoin number? (lambda (x) (and (single-flonum? (imag-part x))
(single-flonum? (real-part x)))))))
-InexactComplex]
[(~var i (3d number?)) -Number] ; otherwise, Number