core.typed

annotating methods that descructure their arguments can confuse the type system

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

In the repro case below, the two examples should be identical, but the latter causes the type system to incorrectly deduce the type of `a` and `b` to be `(U nil Number)` while it is really `Number`.

learning.core=> (cf (fn [[a b] :- (HVec [Num Num])] [(+ a b)]))
[(IFn [(HVec [Num Num]) -> (HVec [java.lang.Number]) :filters {:then tt, :else ff}]) {:then tt, :else ff}]
learning.core=> (cf (fn [[a b] :- (I (Vec Num) (ExactCount 2))] [(+ a b)]))
Type Error (/private/var/folders/34/98dbvkhn7v1clfvl5_y_fkc00001j3/T/form-init2527243481617671751.clj) Static method clojure.lang.Numbers/add could not be applied to arguments:

Domains:
java.lang.Long java.lang.Long
java.lang.Double java.lang.Double
AnyInteger AnyInteger
java.lang.Number java.lang.Number

Arguments:
(U nil Number) (U nil Number)

Ranges:
java.lang.Long
java.lang.Double
AnyInteger
java.lang.Number

in: (clojure.lang.Numbers/add a b)
in: [(clojure.lang.Numbers/add a b)]

ExceptionInfo Type Checker: Found 1 error clojure.core/ex-info (core.clj:4403)
learning.core=>

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: