Skip to content

Commit

Permalink
float-or-complex-float-type handle union types (returned by numeric-c…
Browse files Browse the repository at this point in the history
…ontagion)
  • Loading branch information
ajberkley committed Feb 14, 2021
1 parent 2bec200 commit 67e6754
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/compiler/float-tran.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -619,15 +619,21 @@
;;; should be the right kind of float. Allow bounds for the float
;;; part too.
(defun float-or-complex-float-type (arg &optional lo hi)
(declare (type numeric-type arg))
(let* ((format (case (numeric-type-class arg)
((integer rational) 'single-float)
(t (numeric-type-format arg))))
(float-type (or format 'float))
(lo (coerce-numeric-bound lo float-type))
(hi (coerce-numeric-bound hi float-type)))
(specifier-type `(or (,float-type ,(or lo '*) ,(or hi '*))
(complex ,float-type)))))
(cond
((numeric-type-p arg)
(let* ((format (case (numeric-type-class arg)
((integer rational) 'single-float)
(t (numeric-type-format arg))))
(float-type (or format 'float))
(lo (coerce-numeric-bound lo float-type))
(hi (coerce-numeric-bound hi float-type)))
(specifier-type `(or (,float-type ,(or lo '*) ,(or hi '*))
(complex ,float-type)))))
((union-type-p arg)
(apply #'type-union
(loop for type in (union-type-types arg)
collect (float-or-complex-float-type type))))
(t (specifier-type 'number))))

(eval-when (:compile-toplevel :execute)
;; So the problem with this hack is that it's actually broken. If
Expand Down

0 comments on commit 67e6754

Please sign in to comment.