From b0afc358f376f6721950bdf5f93ed12b61c5bee7 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Wed, 1 Feb 2012 16:38:13 -0500 Subject: [PATCH] Fix type of expt. Closes PR 12526. original commit: 1b6cf730c3ea45f4b76b3b034eb3baf578e9fb7c --- .../tests/typed-racket/optimizer/tests/expt.rkt | 13 +++++++++++++ collects/typed-racket/base-env/base-env-numeric.rkt | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 collects/tests/typed-racket/optimizer/tests/expt.rkt diff --git a/collects/tests/typed-racket/optimizer/tests/expt.rkt b/collects/tests/typed-racket/optimizer/tests/expt.rkt new file mode 100644 index 00000000..1cf3b12f --- /dev/null +++ b/collects/tests/typed-racket/optimizer/tests/expt.rkt @@ -0,0 +1,13 @@ +#; +( +TR missed opt: expt.rkt 13:13 (expt (sin 0.25) 1.0) -- unexpected complex type +TR opt: expt.rkt 13:19 (sin 0.25) -- unary float +) + +#lang typed/racket + +;; PR 12526 +;; result of expt was Float-Complex, and shouldn't have been +;; this let to incorrect optimization +(define (crash) + (real-part (expt (sin 0.25) 1.0))) diff --git a/collects/typed-racket/base-env/base-env-numeric.rkt b/collects/typed-racket/base-env/base-env-numeric.rkt index 6cd8b04f..a9315742 100644 --- a/collects/typed-racket/base-env/base-env-numeric.rkt +++ b/collects/typed-racket/base-env/base-env-numeric.rkt @@ -1594,11 +1594,11 @@ (-PosReal -Real . -> . -PosReal) (-NonNegReal -Real . -> . -NonNegReal) (-Flonum -Integer . -> . -Flonum) - (-Flonum -Real . -> . -FloatComplex) + (-Flonum -Real . -> . N) (-SingleFlonum -Integer . -> . -SingleFlonum) - (-SingleFlonum -SingleFlonum . -> . -SingleFlonumComplex) + (-SingleFlonum -SingleFlonum . -> . (Un -SingleFlonum -SingleFlonumComplex)) (-InexactReal -Integer . -> . -InexactReal) - (-InexactReal -InexactReal . -> . -InexactComplex) + (-InexactReal -InexactReal . -> . (Un -InexactReal -InexactComplex)) (-ExactNumber -ExactNumber . -> . -ExactNumber) (commutative-binop N -FloatComplex) (commutative-binop (Un -ExactNumber -SingleFlonum -SingleFlonumComplex) -SingleFlonumComplex)