Fix sign propagation in some real-complex corner cases.

May have been found using random testing a while back.
This commit is contained in:
Vincent St-Amour 2015-11-12 16:08:15 -06:00
parent fb3dee24db
commit 1187281bf7
2 changed files with 12 additions and 6 deletions

View File

@ -75,13 +75,16 @@
(define c1 (stx-car cs))
(define o-nf (as-non-float o))
(define c1-nf (as-non-float c1))
(if (and o-nf c1-nf)
(if (or o-nf c1-nf)
;; can't convert those to floats just yet, or may change
;; the result
(let ([new-o (quasisyntax/loc this-syntax
(#,op #,o-nf #,c1-nf))])
(loop (mark-as-non-float new-o)
(stx-cdr cs)))
(let ([new-o (mark-as-non-float
(quasisyntax/loc this-syntax
(#,op #,(or o-nf o) #,(or c1-nf c1))))])
(if (stx-null? (stx-cdr cs))
new-o
(loop new-o
(stx-cdr cs))))
;; we've hit floats, can start coercing
(n-ary->binary this-syntax unsafe (cons #`(real->double-flonum #,(or o-nf o)) cs)))))

View File

@ -12,6 +12,9 @@
(provide tests)
;; Test suite that makes sure that TR+opt returns the same results as Racket.
;; Historically contained bugs that we knew about, but had not fixed.
;; Now those are all fixed.
(define (mk-eval lang)
(call-with-trusted-sandbox-configuration
@ -89,7 +92,7 @@
;; Negation should correctly compute sign of 0.0
(good-opt (- 0.0+0.0i))
(bad-opt (- 0+0i 0.0+0.0i))
(good-opt (- 0+0i 0.0+0.0i))
;; Conjugate should correctly compute sign of 0.0
(good-opt (conjugate 0.0+0.0i))))