Add a test case for close-calls on all-real arithmetic expressions.

original commit: 5d4ef5c62478ca1dfeeb5a79d6ed65479283a31f
This commit is contained in:
Vincent St-Amour 2011-05-16 14:44:17 -04:00
parent 968f60d8e1
commit 9d1bfedc5e

View File

@ -0,0 +1,25 @@
#;
(
all-real.rkt 24:0 (#%app + (quote 3) (quote 4)) -- binary, args all float-arg-expr, return type not Float -- caused by: 24:8 (quote 3)
all-real.rkt 25:0 (#%app * (quote 3) (quote 4)) -- binary, args all float-arg-expr, return type not Float -- caused by: 25:8 (quote 3)
7
12
)
#lang typed/racket
;; all-real expressions
;; They currently get reported as missed float optimizations.
;; Whether that's the right thing or not is debatable.
;; pro: more often than not, Real types pop up when the type system can't
;; prove something, but the user really wants a float type, so reporting
;; is likely to be helpful
;; con: all-real expressions can arise from integer-only computations
;; (ex: (+ (sqrt 4) 2) : Positive-Real), so reporting a missed float opt
;; sounds wrong
;; If we decide against reporting these cases in the future, it's only a matter
;; of adding a check to make sure at least one of the subexpressions is in the
;; Float layer in addition to the entire expression being in the Real layer.
(+ (ann 3 Real) (ann 4 Real))
(* (ann 3 Real) (ann 4 Real))