diff --git a/collects/tests/typed-scheme/optimizer/generic/maybe-exact-complex.rkt b/collects/tests/typed-scheme/optimizer/generic/maybe-exact-complex.rkt new file mode 100644 index 00000000..7201c0d4 --- /dev/null +++ b/collects/tests/typed-scheme/optimizer/generic/maybe-exact-complex.rkt @@ -0,0 +1,5 @@ +#lang typed/scheme #:optimize + +(require racket/unsafe/ops) + +(+ 1.0+2.0i 2+4i) diff --git a/collects/typed-scheme/optimizer/inexact-complex.rkt b/collects/typed-scheme/optimizer/inexact-complex.rkt index 3eeaa32b..b1987878 100644 --- a/collects/typed-scheme/optimizer/inexact-complex.rkt +++ b/collects/typed-scheme/optimizer/inexact-complex.rkt @@ -254,11 +254,13 @@ #`((real-binding (exact->inexact #,((optimize) #'e))))) (pattern e:expr #:when (isoftype? #'e -Number) ; complex, maybe exact, maybe not + #:with e* (unboxed-gensym) #:with real-binding (unboxed-gensym) #:with imag-binding (unboxed-gensym) #:with (bindings ...) - #`((real-binding (real-part #,((optimize) #'e))) - (imag-binding (imag-part #,((optimize) #'e))))) + #`((e* #,((optimize) #'e)) + (real-binding (exact->inexact (real-part e*))) + (imag-binding (exact->inexact (imag-part e*))))) (pattern e:expr #:with (bindings ...) (error "non exhaustive pattern match")