First attempt at logging unexpected Real types popping up.

original commit: 7b2c6f5765c2f3b5aefd24f15bbd6f9bf5855749
This commit is contained in:
Vincent St-Amour 2011-05-02 10:46:49 -04:00
parent a2400d8d4b
commit 69b3ea5f28
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,14 @@
#;
(
real-in-float-expr.rkt line 10 col 0 - (#%app * (quote 3) (quote 2.3)) - binary, args all float-arg-expr, return type not Float
6.8999999999999995
6
5
)
#lang typed/racket
(* (ann 3 Real) ; with type Real, typechecker must assume it could be exact 0
2.3)
(* (ann 2 Integer) (ann 3 Integer)) ; but these have nothing to do with floats, should not be logged
(+ (ann 2 Integer) (ann 3 Integer))

View File

@ -86,7 +86,14 @@
f2:float-arg-expr
fs:float-arg-expr ...)
;; if the result is a float, we can coerce integers to floats and optimize
#:when (subtypeof? this-syntax -Flonum)
#:when (let ([safe-to-opt? (subtypeof? this-syntax -Flonum)])
;; if we don't have a return type of float, we missed an optimization
;; opportunity, report it
(when (and (not safe-to-opt?)
(isoftype? this-syntax -Real))
(log-close-call "binary, args all float-arg-expr, return type not Float"
this-syntax))
safe-to-opt?)
#:with opt
(begin (log-optimization "binary float" #'op)
(n-ary->binary #'op.unsafe #'f1.opt #'f2.opt #'(fs.opt ...))))