Elsa icon indicating copy to clipboard operation
Elsa copied to clipboard

Incorrect overload analysis when the input is a "sum" type, but individual type would succeed

Open Fuco1 opened this issue 1 year ago • 0 comments

In case x is int, the first overload could be used, in case x is float, the second could be used. We can't determine the return type (it's int or float) but the call can definitely happen.

image

;; (a :: (and (function (int) int) (function (float) float)))
(defun a (x)
  "asd"
  (cond
   (nil (1+ x))
   ((integerp x) (1+ x))
   ((floatp x) (1+ x))
   (t (error "Impossible"))))


(integerp (a 1.0))
(stringp (a 1))


;; (a :: (and (function (int) int) (function (float) float)))

Fuco1 avatar Feb 11 '23 23:02 Fuco1