<< Back to previous view

[CTYP-29] (fn [x] (map inc [x 2 3])) errors with "Could not apply dotted function" Created: 23/Jul/13  Updated: 15/Sep/13  Resolved: 19/Aug/13

Status: Closed
Project: core.typed
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Alan Busby Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

[org.clojure/core.typed "0.1.17"]


type-examples.core> (t/cf (t/ann-form (fn [x] (map inc [x 2 3])) [Number -> (clojure.lang.LazySeq Number)]))
Type Error (type-examples.core:1:50) Could not apply dotted function (All [v0 v1 v2 ...] (Fn [(Fn [v1 v2 ... v2 -> v0]) (U nil (Seqable v1)) (U nil (Seqable v2)) ... v2 -> (LazySeq v0)])) to arguments [(Fn [t/AnyInteger -> t/AnyInteger] [Number -> Number]) [Number (Value 2) (Value 3)]]
in: (clojure.core/map clojure.core/inc [x 2 3])

Comment by Ambrose Bonnaire-Sergeant [ 01/Aug/13 2:18 PM ]

Unfortunately it seems the type inference isn't good enough to deal with (map f coll), where f has more than one arity and coll triggers one other than the most specific.

(map + [1])
=> (LazySeq AnyInteger)

(map + [1.1]
=> constraint gen error

Workaround: assign f a less accurate type, probably one with just a single arity.

(map (ann-form + [Number -> Number]) [1.1])
=> (LazySeq Number)

The particular issue here can be fixed with:

(cf (fn [x]
(map (ann-form inc [Number -> Number])
[x 2 3]))
[Number -> (clojure.lang.LazySeq Number)])

Comment by Ambrose Bonnaire-Sergeant [ 19/Aug/13 3:52 AM ]

This is not a limitation of LTI.

Comment by Ambrose Bonnaire-Sergeant [ 19/Aug/13 3:52 AM ]

This is a legitimate issue, now fixed on my machine. I must have had a long night when I was porting the Typed Racket constraint generation!

Thanks for the report Alan!

Generated at Sat Oct 21 01:27:25 CDT 2017 using JIRA 4.4#649-r158309.