Actual fix for not suppressing divide-by-0 errors.

This commit is contained in:
Vincent St-Amour 2015-11-09 15:20:04 -06:00
parent 623a29eff4
commit db79beaf12
2 changed files with 21 additions and 0 deletions

View File

@ -132,6 +132,21 @@
#,(mark-as-real res-imag)) ; this case implies real
(values (/ #,first-non-float #,second-non-float)
0.0)]]
[second-non-float
;; may be dividing by exact 0, be conservative to preserve error
;; (res-real can't be non-float, since we've hit a float, so we either
;; error or coerce)
#`[(#,res-real #,(if both-real?
(mark-as-real res-imag)
res-imag))
;; TODO could optimize computation of `res-div` when one or the other is real
(let-values ([(res-div)
(/ (make-rectangular #,a
#,(if first-arg-real? #'0 b))
(make-rectangular #,second-non-float
#,(if second-arg-real? #'0 d)))])
(values (real-part res-div)
(imag-part res-div)))]]
[both-real?
#`[(#,res-real #,(mark-as-real res-imag))
(values (unsafe-fl/ #,a #,c)

View File

@ -0,0 +1,6 @@
#;
(exn-pred "division by zero")
#lang typed/racket
;; float-complex opts should not make div-by-0 errors go away
(* (/ 1.0+1.0i (ann 0 Integer) (ann 0 Integer)) -4.880003479031522e-08)