<< Back to previous view

[CTYP-26] Types should track interfaces not-implemented Created: 26/Jun/13  Updated: 15/Sep/13  Resolved: 02/Jul/13

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

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


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 02/Jul/13 10:14 AM ]

Add Extends type.





[CTYP-43] def should handle an expected type Created: 03/Sep/13  Updated: 04/Sep/13  Resolved: 03/Sep/13

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

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


 Description   

See: https://gist.github.com/arohner/6432328



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 03/Sep/13 11:21 PM ]

Fixed: https://github.com/clojure/core.typed/commit/efb90909b74aca1aaec53d48da49b3f89ebe4fe7





[CTYP-44] Basic type coverage Created: 03/Sep/13  Updated: 04/Sep/13  Resolved: 04/Sep/13

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

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


 Description   

Make a tool that collects annotations in several namespaces and summarises the number of typed vars.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 04/Sep/13 3:09 AM ]

Fixed: https://github.com/clojure/core.typed/commit/99833fc1e79f6cffc3153024bf5c22c3c811180f

and

https://github.com/frenchy64/lein-typed/commit/a8ad6b95442385d36af2354adf2bbceb5c8d8c4a





[CTYP-19] ann-form requires fully qualified classnames Created: 10/Mar/13  Updated: 15/Sep/13  Resolved: 29/Mar/13

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

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


 Description   

Classes imported into a namespace are visible to clojure.core.type/ann without qualification, but require full qualification with 'clojure.core.type/ann-form.

For example:

(ns ring.typed.util.data
  "Miscellaneous functions for manipulating data structures."
  (:require [clojure.core.typed :refer [ann ann-form]])

  (:import (clojure.lang IPersistentVector
                         IPersistentMap)))

(ann assoc-conj
     (All [x] (Fn [(IPersistentMap Any (U x (IPersistentVector (U Any x)))) Any x -> 
                   (IPersistentMap Any (U x (IPersistentVector x)))]
                  [(IPersistentVector (U x (IPersistentVector x))) Integer x ->
                   (IPersistentVector (U x (IPersistentVector x)))])))
(defn assoc-conj
  "Associate a key with a value in a map. If the key already exists in the map,
  a vector of values is associated with the key."
  [map key val]
  (assoc map key
    (if-let [cur (get map key)]
      (if (vector? cur)
        (ann-form (conj cur val)
                  (IPersistentVector x))
        [cur val])
      val)))

This results in a "Cannot parse list: (IPersistentVector x)" Exception

When

(ann-form (conj cur val)
                  (IPersistentVector x))

is changed to

(ann-form (conj cur val)
                  (clojure.lang.IPersistentVector x))

checking works.

I have been running check-ns from the 'user namespace



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 10/Mar/13 9:25 PM ]

Confirmed. This is due to running the type checker in a namespace other than the namespace being checked.

Comment by Ambrose Bonnaire-Sergeant [ 29/Mar/13 7:50 AM ]

Fixed: https://github.com/clojure/core.typed/commit/0d195fbc879f5e62051ec922ffbd2c8ada4a194a





[CTYP-7] Add Typed Namespace Support Created: 03/Mar/13  Updated: 15/Sep/13  Resolved: 07/Apr/13

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

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


 Description   

We need a way to specify typed dependencies. Things like `typed-load`, `typed-require` etc.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 07/Apr/13 9:16 PM ]

0.1.12 contains `typed-deps` for declaring dependencies.





[CTYP-24] Test all destructuring kinds Created: 25/Mar/13  Updated: 15/Sep/13  Resolved: 13/Apr/13

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

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


 Description   

Some destructuring idioms are troublesome. Review the commented out tests in destructuring-special-ops.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 13/Apr/13 7:37 PM ]

Tested many cases here https://github.com/clojure/core.typed/blob/3f3a32a118dda3f0e1d479b0a3d9ea21b57109e1/src/test/clojure/clojure/core/typed/test/destructure.clj

We could be more accurate in some cases, but it's good enough for now.





[CTYP-17] Decomposition Alms inference phase Created: 09/Mar/13  Updated: 15/Sep/13  Resolved: 13/Apr/13

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

Type: Task Priority: Major
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Declined Votes: 0
Labels: None


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 13/Apr/13 7:38 PM ]

This can wait.





[CTYP-21] Checker passes ill-typed protocol method implementation Created: 20/Mar/13  Updated: 15/Sep/13  Resolved: 20/Mar/13

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

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


 Description   

Described here: https://groups.google.com/forum/?fromgroups=#!topic/clojure-core-typed/AuWQdDxv7hs



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Mar/13 9:16 PM ]

Can't reproduce: https://github.com/clojure/core.typed/blob/master/src/test/clojure/clojure/core/typed/test/core.clj#L1210

Comment by Ambrose Bonnaire-Sergeant [ 20/Mar/13 11:46 PM ]

Actually, an earlier commit fixed the issue: https://github.com/clojure/core.typed/commit/59cb1c43e49b8dccb566756d5836a31958beec31

:new wasn't checking its result type against its expected type.

Fixed, verified by above test.





[CTYP-23] Filters inferred from `and` macro are not useful Created: 25/Mar/13  Updated: 15/Sep/13  Resolved: 25/Mar/13

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

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


 Description   

We aren't handling `and`'s macroexpansion well. This probably has something to do with the composite filter constructors -and and -or, and how they simplify their members.

(deftest let-filter-unscoping-test
  (is (cf (fn [a]
            (and (< 1 2) a))
          [(U nil Number) -> Any :filters {:then (is Number 0)}])))


ERROR in (let-filter-unscoping-test) (subtype.clj:24)
expected: (cf (fn [a] (and (< 1 2) a)) [(U nil Number) -> Any :filters {:then (is Number 0)}])
  actual: java.lang.Exception: Type Error, REPL:3

Actual type
	(Fn [(U java.lang.Number nil) -> (U java.lang.Number false nil) {:then (| (! (U false nil) 0) tt), :else (| (is (U false nil) 0) tt)}])
is not a subtype of Expected type
	(Fn [(U java.lang.Number nil) -> Any {:then (is java.lang.Number 0), :else tt}])

Form: (fn* ([a] (let* [and__3941__auto__ (clojure.lang.Numbers/lt 1 2)] (if and__3941__auto__ a and__3941__auto__))))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 25/Mar/13 9:46 AM ]

Fixed. https://github.com/clojure/core.typed/commit/87040592b383436bf37bd3908727335f3d29e2b3





[CTYP-2] Support looping macros Created: 03/Mar/13  Updated: 15/Sep/13  Resolved: 26/Mar/13

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

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


 Description   

Work out how to support `for`, `doseq` and friends.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 26/Mar/13 5:43 AM ]

Added doseq>, for> and dotimes>.





[CTYP-30] Iterable should be Seqable Created: 23/Jul/13  Updated: 15/Sep/13  Resolved: 01/Aug/13

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

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

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



 Description   

From mail;
> > Does (first (seq iterable)) work for you?
>
> No, seq only takes "(I (Seqable x) (CountRange 1))" and "(t/Option (Seqable x))".

Sigh. seq probably needs a few more arities to we need to "trick" core.typed into
thinking Iterable is a Seqable (eg. String is a Seqable to core.typed).



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 01/Aug/13 10:30 AM ]

Fixed: https://github.com/clojure/core.typed/commit/9bb6ef544f57d17ff8a57abd142ca8c724aebb08





[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
Environment:

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



 Description   

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])



 Comments   
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.

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

(map + [1.1]
=> constraint gen error

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

eg.
(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!





[CTYP-34] Handle checking defmethods correctly Created: 19/Aug/13  Updated: 15/Sep/13  Resolved: 28/Aug/13

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

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


 Description   

The current strategy of using a dispatch function to update defmethods before we check them is buggy. Specifically scoping is broken.

Instead of superficial fixes, this needs further thought. Probably best to have a function that takes the multimethod type & a dispatch value, and returns a new expected type for the defmethod.

Currently we simulate injecting a new expression directly inside the defmethod. This is broken.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 28/Aug/13 8:09 AM ]

Fixed this in 0.1.25 by abstracting all elements of a Result (Typed Racket does not abstract the type).





[CTYP-42] ClassNotFoundException raised when checking annotations for records that extend a protocol Created: 03/Sep/13  Updated: 15/Sep/13  Resolved: 09/Sep/13

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

Type: Defect Priority: Major
Reporter: Michael Hanson Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

clojure.core.typed 0.2.2



 Description   

Regression from 0.2.1. See https://gist.github.com/mybuddymichael/0187fa3dcd7ce79e7e0d

The exception is raised with both inline protocol extension and when using extend-type. It is not raised when a record is not extending a protocol.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 04/Sep/13 3:18 AM ]

Confirmed.

Comment by Ambrose Bonnaire-Sergeant [ 04/Sep/13 6:48 AM ]

Actually I'm having trouble reproducing on 0.2.4-20130904.114526-5

Could you try Michael?

Comment by Michael Hanson [ 04/Sep/13 11:19 AM ]

I upgraded but I'm still seeing the issue in both the code above and in my production application's code.

Comment by Ambrose Bonnaire-Sergeant [ 05/Sep/13 2:03 AM ]

Oh boy, this might be quite involved to diagnose. :/

Comment by Michael Hanson [ 06/Sep/13 10:22 AM ]

Oops, sorry. Is there anything I can do to dig deeper into this?

Comment by Ambrose Bonnaire-Sergeant [ 08/Sep/13 6:21 AM ]

Potential fix: https://github.com/clojure/core.typed/commit/e0598562570184894afdaeb64b6ab20242102d09

Please verify with: 0.2.5-20130908.112056-6

Comment by Ambrose Bonnaire-Sergeant [ 09/Sep/13 12:08 PM ]

Michael reported this as fixed.





[CTYP-67] core.typed doesn't interact well with inlining Created: 21/Sep/13  Updated: 25/Sep/13  Resolved: 25/Sep/13

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

Type: Defect Priority: Major
Reporter: Julian Birch Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug


 Description   

(cf compare)

gives

(Fn [Comparable Any -> Number])

but

(cf (fn [v x] (compare v x)) (Fn [Comparable Any -> Number]))

fails the type check.

(Credit: cspent on IRC figured out that the problem was that it was inlining the compare function, and therefore not using the annotation.)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 25/Sep/13 3:24 AM ]

Fixed https://github.com/clojure/core.typed/commit/044434b33c4d9ce1df95170bfff3c45a9c2cdbb6





[CTYP-66] Improve type preservation of heterogenous types in assoc/dissoc/merge/conj Created: 20/Sep/13  Updated: 25/Sep/13  Resolved: 20/Sep/13

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

Type: Enhancement Priority: Major
Reporter: Chris Spencer Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File heterogenous-improvements.patch     Text File heterogenous-improvements-squashed.patch    
Patch: Code and Test

 Description   

Adds better type preservation through assoc/dissoc/merge/conj with some hopefully reuseable groundwork for those operations to be used in other areas.



 Comments   
Comment by Chris Spencer [ 20/Sep/13 6:38 PM ]

Squashed the commits together into one

Comment by Ambrose Bonnaire-Sergeant [ 20/Sep/13 8:45 PM ]

Applied in 0.2.8





[CTYP-65] You can't declare a protocol in a namspace with no dots Created: 20/Sep/13  Updated: 25/Sep/13  Resolved: 21/Sep/13

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

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


 Description   

There's an assert that checks for the presence of a dot in a namespace. Which is a pain if you don't have one.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 21/Sep/13 12:47 PM ]

Fixed in 0.2.9





[CTYP-62] comparison with value from (HMap) leads to erroneous always-true Created: 15/Sep/13  Updated: 25/Sep/13  Resolved: 18/Sep/13

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

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


 Description   

Following should be (U (Value 5) (Value 6)) I think (given no knowledge of the {} keys)

user=> (cf (if (= (:a (ann-form {} (HMap)))
                  "6")
               5 6))
[(Value 5) {:then tt, :else ff}]

I think the smaller case is:

user=> (cf (= (:a (ann-form {} (HMap))) "6"))
[(U true false) {:then tt, :else ff}]


 Comments   
Comment by Chris Spencer [ 15/Sep/13 5:21 PM ]

Maybe helpful for debugging, correct and incorrect smaller cases:

user=> (cf (= (ann-form 1 Any) 3))
(U true false)
user=> (cf (= (ann-form 1 Any) "3"))
[(U true false) {:then tt, :else ff}]
user=> (cf (= (ann-form 1 Any) {}))
[(U true false) {:then tt, :else ff}]
Comment by Ambrose Bonnaire-Sergeant [ 18/Sep/13 4:44 AM ]

Fixed with https://github.com/clojure/core.typed/commit/1fa44df8c1e341be333f06562a807f73d38ecda2

Please verify with 0.2.8-20130918.094405-3





[CTYP-61] assoc derives imprecise type when optional attributes present Created: 15/Sep/13  Updated: 25/Sep/13  Resolved: 20/Sep/13

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

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


 Description   

"Real world" use case, removing the optional forename makes things work as expected:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(def-alias TUser (HMap :mandatory {:group String}
                       :optional {:forename String}
                  ))
(def-alias TAdmin (HMap :mandatory {:group (Value "admin")}
                        :optional {:forename String}
                  ))

(ann my-user TUser)
(def my-user {:group "whee"})

(ann my-admin TAdmin)
(def my-admin (assoc my-user :group "admin"))

Smaller test case:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(cf (assoc
      (ann-form {} (HMap :optional {:a Any}))
      :b "v")
    (HMap :mandatory {:b (Value "v")} :optional {:a Any}))


 Comments   
Comment by Chris Spencer [ 15/Sep/13 11:03 AM ]

s/attributes/keys

Comment by Chris Spencer [ 15/Sep/13 3:07 PM ]

Ah i see this in a TODO in check.clj#L2120

Comment by Chris Spencer [ 15/Sep/13 4:28 PM ]

I had a quick stab at this, just to try and learn the code a bit:
https://github.com/c-spencer/core.typed/commit/c675662004b03241df596978d897cb254973bd63

Just runs the original inner update over the union. I moved the inner part out to a supporting function just to make things clearer for myself..

Passes some cursory checks, and I added a couple of simple test cases in the following commit.

user=> (cf (assoc (ann-form {} (HMap :optional {:a Any})) :b "v"))
[(U (HMap :mandatory {:b (Value "v"), :a Any}) (HMap :mandatory {:b (Value "v")} :absent-keys #{:a})) {:then tt, :else ff}]
user=> (cf (assoc (ann-form {} (HMap :optional {:b Any})) :b "v"))
[(HMap :mandatory {:b (Value "v")}) {:then tt, :else ff}]
Comment by Ambrose Bonnaire-Sergeant [ 20/Sep/13 8:42 PM ]

Fixed in 0.2.8

https://github.com/clojure/core.typed/blob/74d24b8228c65b4d3158ec716830549fa9e1cd75/src/test/clojure/clojure/core/typed/test/core.clj#L2011





[CTYP-60] HMap :optional fields behaving oddly, hole in the type system Created: 14/Sep/13  Updated: 25/Sep/13  Resolved: 15/Sep/13

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

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


 Description   

user=> (cf {:a "a"} (HMap :optional {:a Number}))
(U (HMap :mandatory {} :absent-keys #{:a}) (HMap :mandatory {:a Number}))

I would expect this to fail to type, and it points out the following hole in the type system:

(ann odd-type [-> (U (HMap :mandatory {} :absent-keys #{:a})
(HMap :mandatory {:a Number}))])
(defn odd-type [] {:a "a"})

(ann wrong-type [-> (HMap :mandatory {:a Number})])
(defn wrong-type []
(let [a (odd-type)]
(assert (get a :a))
(print-env "my-types")
a))

print-env:
{:env {a (HMap :mandatory {:a java.lang.Number})}, :props ((is (U java.lang.Number nil) a [(Key :a)]))}



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 15/Sep/13 8:44 AM ]

Fixed: https://github.com/clojure/core.typed/commit/0e6d4c4d358a55539b569c51935033646044d6dd

Please verify with: [org.clojure/core.typed "0.2.6-20130915.134318-3"]

Comment by Ambrose Bonnaire-Sergeant [ 15/Sep/13 8:56 AM ]

Verified via IRC.





[CTYP-40] Annotations for function types don't work in ClojureScript Created: 02/Sep/13  Updated: 25/Sep/13  Resolved: 10/Sep/13

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

Type: Defect Priority: Major
Reporter: Chris Frisz Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: cljs
Environment:

Safari 6.0.5 and Firefox 22.0 on Mac OS X 10.8.4



 Description   

Function type annotation in ClojureScript causes a failure in the type checker:

AssertionError Assert failed: No check-fn bound for rest type
check-fn-method1-rest-type clojure.core.typed.check/check-fn-method1 (check.clj:2953)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 07/Sep/13 9:00 AM ]

This should be fixed in 0.2.5-20130907.135349-4

Please give it a shot.

Comment by Chris Frisz [ 10/Sep/13 10:41 PM ]

Tried the same code again with the suggested revision and the issue seems to be fixed. Thanks!





[CTYP-53] HMap update simplifies to Nothing too eagerly Created: 11/Sep/13  Updated: 25/Sep/13  Resolved: 15/Sep/13

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

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


 Description   

The following code should type check to [(HMap) -> (HMap :mandatory {:foo (Vec Any)})].

(cf
(fn> [m :- (HMap)]
(assert (vector? (:foo m)))
m))
;=> [(HMap) -> Nothing]

The source of this bug is the HMap being updated incorrectly:

(clj
(update (parse-type '(HMap))
(parse-filter '(is (clojure.core.typed/Vec Any) m [(Key :foo)]))))
;=> Nothing



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 15/Sep/13 8:44 AM ]

Fixed: https://github.com/clojure/core.typed/commit/ad9c1769689809278fef3bbd50bf2efa4864be12





[CTYP-46] ann-record's field syntax is undocumented Created: 04/Sep/13  Updated: 25/Sep/13  Resolved: 15/Sep/13

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

Type: Enhancement Priority: Major
Reporter: Timo Mihaljov Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

ann-record's docstring says "Annotate record Class name dname with expected fields", but it does not specify the syntax that it expects for the fields. The Quick Guide and Types pages on the Wiki don't mention it either.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 15/Sep/13 8:45 AM ]

Fixed: https://github.com/clojure/core.typed/commit/46301216761b7588937cf14eea03b832fa92ceac





[CTYP-37] Implementing protocol method in deftype throws meaningless error Created: 28/Aug/13  Updated: 25/Sep/13  Resolved: 15/Sep/13

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

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


 Description   

Reported by Michael Hanson.

https://gist.github.com/mybuddymichael/065c7f8090aa19efd82f



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 15/Sep/13 9:14 AM ]

Now throws a type system error. https://github.com/clojure/core.typed/commit/1d79998b31103b61b67d58e964a6cc90c9718405

Fixed in 0.2.6-20130915.134318-3





[CTYP-69] Unadorned record produces stack trace rather than a "unchecked" response Created: 22/Sep/13  Updated: 25/Sep/13  Resolved: 22/Sep/13

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

Type: Enhancement Priority: Major
Reporter: Julian Birch Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

(ns spong
(:require [clojure.core.typed :refer :all]))

(defrecord X [x])

; lein typed check spong

If you've got a few types, it's impossible to track it down.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 22/Sep/13 9:12 PM ]

This might be a regression from 0.2.9.

Fixed with https://github.com/clojure/core.typed/commit/dc6a69cccf8a0356d97fd6144141dff2b22113f9

Verify with 0.2.10-20130923.021130-2





[CTYP-64] Improvements to Error Messsages Created: 20/Sep/13  Updated: 09/Oct/13  Resolved: 25/Sep/13

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

Type: Enhancement Priority: Major
Reporter: Julian Birch Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

These are a bunch of "if you do stupid things, it doesn't help"

1) If you do ann-datatype on a record, error message is incomprehensible.
2) ```clj
(ann-protocol IValidator
validate- [Term Any])
```
crashes and doesn't explain what's wrong with the syntax.
3) So does
(ann-protocol IValidator
validate- [[Term Any] -> Any])



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 21/Sep/13 12:47 PM ]

The error message for ann-datatype'ing a record should be much clearer in 0.2.9. Please verify.

Comment by Julian Birch [ 22/Sep/13 9:42 AM ]

(ann-datatype X [x :- Number])
(defrecord X [x])

gives

5: Reference to untyped binding: __meta
Hint: Add the annotation for __meta via check-ns or cf

which still seems pretty confusing. Sorry if I'm doing something wrong here.

Comment by Ambrose Bonnaire-Sergeant [ 23/Sep/13 3:46 AM ]

Yes, I fixed the wrong bug.

Comment by Ambrose Bonnaire-Sergeant [ 23/Sep/13 10:57 AM ]

Should really be fixed in 0.2.10

Comment by Ambrose Bonnaire-Sergeant [ 25/Sep/13 3:29 AM ]

Fixed in master:

Addressing point 2:

(cf (ann-protocol IValidator
                  validate- [Term Any]))
ExceptionInfo Internal Error (clojure.core.typed.test.core:1:34) Incorrect function syntax: [Term Any]  clojure.core/ex-info (core.clj:4327)

Point 3:

(cf (ann-protocol IValidator
                  validate- [[Term Any] -> Any]))
ExceptionInfo Internal Error (clojure.core.typed.test.core:1:34) Incorrect function syntax: [Term Any]  clojure.core/ex-info (core.clj:4327)




[CTYP-68] assoc, update-in &c have record-hostile types Created: 22/Sep/13  Updated: 09/Oct/13  Resolved: 25/Sep/13

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

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


 Description   

(use 'clojure.core.typed)
nil
user=> (ann-record X [x :- Number])
nil
user=> (defrecord X [x])
user.X
user=> (cf (assoc (X. 3) :x 3) X)

0.2.7 thought this should be (Map Any Any)
0.2.9 just thinks you can't do it at all

but it should pass.



 Comments   
Comment by Chris Spencer [ 22/Sep/13 10:59 AM ]

Had a quick look

; inside assoc-type-pairs
(println t (type t) (r/Record? t))

; repl
(ann-record X [x :- Number])
(defrecord X [x])
(cf (assoc (X. 3) :x 3) X)
; debug: user.X clojure.core.typed.type_rep.RClass false

So looks like result of (X. 3) is being instantiated as an RClass rather than a DataType?

Comment by Chris Spencer [ 22/Sep/13 11:12 AM ]

Found issue:

(cf (ann-record X [x :- Number]))
(cf (assoc (X. 3) :x 3))
; user.X clojure.core.typed.type_rep.DataType true

ann-record doesn't collect so need to wrap in a cf, just awkward

Comment by Ambrose Bonnaire-Sergeant [ 22/Sep/13 10:07 PM ]

Global annotations are only collected during type checking.

I've tried to document this, but it seems to frequently trip people up. I've tried to ensure error messages based on missing annotations emphasise annotations must be provided via cf.

eg. https://github.com/clojure/core.typed/wiki/Quick-Guide#type-checking-is-separate-to-compilation-and-must-be-explicitly-run

FWIW this might change in the future to defonce semantics.

There are a couple of other issues here.

1. The Java constructor X. type checked because datatype constructors are normal Java constructors that take Object. ann-record overrides constructors to take the field types.

A couple of approaches to fixing this:

  • warn if constructing an IType or IRecord that is unannotated
  • recommend avoiding the Java constructor in favour of the positional factory.

2. update-in is NYI, ticket here http://dev.clojure.org/jira/browse/CTYP-8

3. assoc might be too strict now. X implements IPersistentMap, so it should be able to assoc anything even if it is unannotated.

(cf (assoc (X. 3) :x 3)) should return (IPersistentMap Any Any).

(defrecord X [x])
(cf (assoc (X. 3) :x 3))

Type Error (clojure.core.typed:1:34) Cannot assoc args `[(Value :x) {:then tt, :else ff}] [(Value 3) {:then tt, :else ff}]` on clojure.core.ty
ped.X
ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.clj:4327)
Comment by Julian Birch [ 24/Sep/13 2:58 PM ]

OK, assoc seems to be behaving itself under 0.2.11.

I should point out I'm using lein typed most of the time, so I'm not that familiar with the repl. I should probably confine myself to submitting scripts that lein typed can run...

This passed, and I think should pass:

(ann-record X [x :- Number])
(defrecord X [x])
(ann Z [-> X])
(defn Z [] (assoc (X. 3) :x 3))

Comment by Ambrose Bonnaire-Sergeant [ 25/Sep/13 3:13 AM ]

Ok. Also it would be helpful to include the actual type error or stacktrace in issues.





[CTYP-77] Type Error Cannot invoke type: Keyword with non-literal keywords Created: 02/Oct/13  Updated: 09/Oct/13  Resolved: 09/Oct/13

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

Type: Defect Priority: Major
Reporter: Gordon Syme Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

project.clj:

(defproject clojure-programming "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/core.typed "0.2.13"]]
:main clojure-programming.core)



 Description   

Using non-literal keywords for map lookup results in "Type Error Cannot invoke Keyword"

Code to reproduce:

(ns foo
  (:require [clojure.core.typed :as t])
  (:import clojure.lang.Keyword))

(t/ann bar [Keyword -> Number])
(defn bar [k]
  (k {:a 1 :b 2}))

Repl:

clojure-programming.core=> (check-ns 'foo)
Initializing core.typed ...
Loading Clojurescript...
Clojurescript not found
"Elapsed time: 2419.011 msecs"
core.typed initialized.
Start collecting foo
Finished collecting foo
Collected 1 namespaces in 2507.171 msecs
Start checking foo
Checked foo in 64.561 msecs
Type Error (foo:7:3) Cannot invoke type: Keyword
in: (k (quote {:a 1, :b 2}))

ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.clj:4327)


 Comments   
Comment by Gordon Syme [ 02/Oct/13 5:38 AM ]

(get m k) and (m k) are also erroring out for me:

Code:

(t/ann baz [Keyword -> Number])
(defn baz [k]
  (get {:a 1 :b 2} k))

(t/ann qux [Keyword -> Number])
(defn qux [k]
  ({:a 1 :b 2} k))

Repl:

Type Error (foo:11:3) Polymorphic static method clojure.lang.RT/get could not be applied to arguments:
Polymorphic Variables:
	x
	y

Domains:
	(clojure.lang.IPersistentSet x) Any
	nil Any
	(t/Option (clojure.lang.ILookup Any x)) Any
	java.util.Map Any
	java.lang.String Any
	(clojure.lang.IPersistentSet x) Any y
	nil Any y
	(t/Option (clojure.lang.ILookup Any x)) Any y
	java.util.Map Any y
	java.lang.String Any y

Arguments:
	(HMap :mandatory {:b (Value 2), :a (Value 1)} :complete? true) clojure.lang.Keyword

Ranges:
	(t/Option x)
	nil
	(t/Option x)
	(t/Option Any)
	(t/Option java.lang.Character)
	(U y x)
	y
	(U y x)
	Any
	(U y java.lang.Character)

with expected type:
	java.lang.Number

in: (clojure.lang.RT/get (quote {:a 1, :b 2}) k)
in: (clojure.lang.RT/get (quote {:a 1, :b 2}) k)


Type Error (foo:15:3) Cannot invoke type: (HMap :mandatory {:b (Value 2), :a (Value 1)} :complete? true)
in: ((quote {:a 1, :b 2}) k)
Comment by Gordon Syme [ 02/Oct/13 7:27 AM ]

The 'get' failure was due to me using an incorrect return type (should have been (U nil Number))

Comment by Ambrose Bonnaire-Sergeant [ 09/Oct/13 8:06 PM ]

Fixed https://github.com/clojure/core.typed/commit/46ac96ce7b42fc2191710e057716e03508c8d0e5





[CTYP-73] Support reduced, reduced? and @ of reduced items. Created: 29/Sep/13  Updated: 09/Oct/13  Resolved: 09/Oct/13

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

Type: Enhancement Priority: Major
Reporter: Julian Birch Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Not sure if this is a defect or enhancement, but there doesn't seem to be any support for reduced.

Arguably, the type declaration of reduce is wrong at the moment, and should be something like

[[a c -> (U a (Reduced a))] (NonEmptySeqable c) -> (U a (Reduced a))]

And I'd like to be able to type check the following

(let [v (reduce f coll)]
(if (reduced? v) @v v))



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Oct/13 8:08 PM ]

Fixed https://github.com/clojure/core.typed/commit/a75e1834be5c6cc6c329ec9f882a35b275f0f70a

Comment by Ambrose Bonnaire-Sergeant [ 09/Oct/13 8:09 PM ]

As a side note, your last usage of reduced is probably not what you meant, as reduce unwraps one layer of reduced.





[CTYP-82] clojure.core.async/alts!! annotation does not account for returning nil values Created: 03/Oct/13  Updated: 09/Oct/13  Resolved: 09/Oct/13

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

Type: Defect Priority: Major
Reporter: Michael Hanson Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

clojure.core.typed 0.2.13



 Description   

The current annotation for clojure.core.async/alts can be seen here: https://github.com/clojure/core.typed/blob/2e4f691d989d7b063d2e43f6f3d3395c0aeb16b5/src/main/clojure/clojure/core/typed/async.clj#L136

I believe it needs to be updated to account for returning a nil value if the channel is closed, or if the operation is a put, given the doc for alts!/alts!!:

clojure.core.async/alts!
([ports & {:as opts}])
Completes at most one of several channel operations. Must be called
inside a (go ...) block. ports is a vector of channel endpoints, which
can be either a channel to take from or a vector of
[channel-to-put-to val-to-put], in any combination. Takes will be
made as if by <!, and puts will be made as if by >!. Unless
the :priority option is true, if more than one port operation is
ready a non-deterministic choice will be made. If no operation is
ready and a :default value is supplied, [default-val :default] will
be returned, otherwise alts! will park until the first operation to
become ready completes. Returns [val port] of the completed
operation, where val is the value taken for takes, and nil for puts.

opts are passed as :key val ... Supported options:

:default val - the value to use if none of the operations are immediately ready
:priority true - (default nil) when true, the operations will be tried in order.

Note: there is no guarantee that the port exps or val exprs will be
used, nor in what order should they be, so they should not be
depended upon for side effects.

So presumably the annotation should be something more like this: https://gist.github.com/mybuddymichael/b209294b52171c875a01



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Oct/13 8:12 PM ]

Fixed https://github.com/clojure/core.typed/commit/88a6e868ebc6f58362e089dfd4d5060e340c379c





[CTYP-84] seq on non-empty sequence should not be nilable Created: 05/Oct/13  Updated: 09/Oct/13  Resolved: 09/Oct/13

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

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


 Description   

E.g. (cf (seq '(1)) (t/NonEmptySeq Number))



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Oct/13 8:14 PM ]

Fixed https://github.com/clojure/core.typed/commit/aa4058ec77ceeb8cbfdd9b468ff1a4fbfaa41ad8





[CTYP-85] Assertion error in abo Created: 05/Oct/13  Updated: 20/Oct/13  Resolved: 20/Oct/13

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

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


 Description   

[10:29:10] hugod: I'm getting "AssertionError Assert failed: (symbol? y) clojure.core.typed.check/abo/lookup--34688 (check.clj:2906)" - trying to work out what abo does...
[10:31:00] ambrosebs: hugod: IIRC it's "abstract object"
[10:31:40] ambrosebs: hugod: it's how we abstract an "object" in the occurrence typing sense from a local name (symbol) to a position arg
[10:32:13] ambrosebs: ie. how we convert (fn [a] a) into (All [x] [x -> x :object {:id 0}])
[10:32:32] ambrosebs: hugod: unsure of where the error is coming from tho
[10:33:04] hugod: this is what it is checking https://www.refheap.com/19405
[10:34:50] hugod: at least that is what is at the last line number reported by :trace true



 Comments   
Comment by Greg Hawkins [ 15/Oct/13 1:48 PM ]

The following minimal example causes this error for me:

(ann minimal [Keyword -> [Any -> Any]])
(defn minimal [kw]
  (fn [b]
    b))

Whereas the following doesn't:

(ann minimal [Keyword -> [Any -> Any]])
(defn minimal [kw]
  (fn [b]
    nil))
Comment by Ambrose Bonnaire-Sergeant [ 20/Oct/13 2:15 AM ]

Thanks Greg, made fixing this easy.

Fixed https://github.com/clojure/core.typed/commit/15684f8a9de37237194a9c79ec7440606f48434f





[CTYP-78] finally blocks are incorrectly type checked against the enclosing form's type Created: 02/Oct/13  Updated: 21/Oct/13  Resolved: 09/Oct/13

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

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


 Description   
(ns finally
  (:require [clojure.core.typed :refer :all]))

(ann f [-> String])
(defn f []
  (try
    "a"
    (finally 1)))

`(check-ns 'finally)` results in

;; Type Error (finally:5) Type mismatch:
;; Expected: 	java.lang.String
;; Actual: 	(Value 1)
;; in: 1
;; ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.clj:4327)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Oct/13 8:11 PM ]

Fixed https://github.com/clojure/core.typed/commit/20b1682f68733d657bf1984b8dd997a00228bb63





[CTYP-95] I believe clojure.core/reset! has the wrong return type Created: 11/Nov/13  Updated: 18/Nov/13  Resolved: 18/Nov/13

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

Type: Defect Priority: Major
Reporter: Michael Hanson Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

core.typed 0.2.19



 Description   

The doc for reset! indicates that it returns the new value, which means, I believe, that the return type of reset! should be w instead of r.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 15/Nov/13 8:02 AM ]

Yes, I think you're right. Thanks.

Comment by Ambrose Bonnaire-Sergeant [ 18/Nov/13 8:32 AM ]

Fixed https://github.com/clojure/core.typed/commit/56366cfd9382253d0e67439d7937b55f75e215c6





[CTYP-74] On missing Fn (or superfluous parens), an assert is raised, with no location information Created: 29/Sep/13  Updated: 18/Nov/13  Resolved: 09/Oct/13

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

Type: Enhancement Priority: Major
Reporter: Hugo Duncan Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

With an expression which ommits a Fn (or alternatively uses extra parens) like:

(ann my-var ([T -> T)))

an assert is raised with no location information:

Assert failed: ((some-fn Name? TypeFn? F? B? Poly?) rator)  clojure.core.typed.type-rep/TApp-maker (type_rep.clj:359)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Oct/13 8:10 PM ]

Fixed https://github.com/clojure/core.typed/commit/edeb6cf572c48792a4bf0f025001e4f35a7bfb70





[CTYP-36] Poly-names* should generate fresh names Created: 27/Aug/13  Updated: 18/Nov/13  Resolved: 11/Nov/13

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

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


 Description   

Otherwise caching is unsound.

Also, type bounds should probably live in the bound or free variable as a hash-able field, rather than in a dynamic binding when unwrapping binders.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 11/Nov/13 8:27 AM ]

Added Poly-fresh*





[CTYP-101] Version 0.2.21 not allows (first {:of :Map}) Created: 09/Jan/14  Updated: 04/Feb/14  Resolved: 21/Jan/14

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

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


 Description   

Following code passes type checks in version 0.2.19 and 0.2.20, but fails in 0.2.21.

(ns bug.core
  (:require [clojure.core.typed :as typed :refer [ann Keyword Int Option]]))

(ann f [(clojure.lang.IPersistentMap Keyword Int) -> (Option (clojure.lang.IMapEntry Keyword Int))])
(defn f [m] (first m))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 11/Jan/14 7:04 AM ]

Confirmed.

Comment by Ambrose Bonnaire-Sergeant [ 21/Jan/14 4:06 AM ]

Fix will be included in 0.2.22.

Passing test: https://github.com/clojure/core.typed/blob/master/src/test/clojure/clojure/core/typed/test/CTYP_101_mapentry.clj





[CTYP-96] clojure.core/iterate has wrong return type Created: 13/Nov/13  Updated: 13/Feb/14  Resolved: 13/Feb/14

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

Type: Defect Priority: Major
Reporter: Stephen Compall Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

Clojure 1.5.1


Attachments: Text File 0001-clojure.core-iterate-returns-with-cons-not-lazy-seq.patch    
Patch: Code

 Description   
user> (clojure-version)
"1.5.1"
user> (class (iterate inc 0))
clojure.lang.Cons

As opposed to the current LazySeq return type.

Also at https://github.com/clojure/core.typed/pull/4



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 15/Nov/13 8:06 AM ]

This is starting to make me rethink what a clojure.core docstring means exactly by a "lazy sequence".

Comment by Ambrose Bonnaire-Sergeant [ 17/Nov/13 10:01 PM ]

I'm going to change all functions that return LazySeq to Seq.

Comment by Ambrose Bonnaire-Sergeant [ 13/Feb/14 7:22 AM ]

Using Seq as return types.





[CTYP-120] Can't use polymorphic records Created: 13/Mar/14  Updated: 14/Mar/14  Resolved: 14/Mar/14

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

Type: Defect Priority: Major
Reporter: Gary Fredericks Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

core.typed 0.2.36



 Description   

The following code fails at load time with CompilerException clojure.lang.ArityException: Wrong number of args (0) passed to: errors/int-error, compiling:

(ns polymorphic.records                                                                                                                                                                                  
  (:require [clojure.core.typed :as t]))                                                                                                                                                            

(t/ann-record [[t :variance :invariant]]                                                                                                                                                            
              Collector                                                                                                                                                                             
              [coll :- (t/Coll t)])                                                                                                                                                                 
(defrecord Collector [coll])                                                                                                                                                                        

(t/ann collector-maker                                                                                                                                                                              
       (TFn [t] [(t/Coll t) -> (Collector t)]))                                                                                                                                                     
(defn collector-maker                                                                                                                                                                               
  [coll]
  (->Collector coll))


 Comments   
Comment by Gary Fredericks [ 13/Mar/14 9:49 AM ]

I see that s/TFn/All/ makes this load without incident and type-check; I guess that was the real problem?

Comment by Ambrose Bonnaire-Sergeant [ 14/Mar/14 7:15 AM ]

Fixed https://github.com/clojure/core.typed/commit/815225d5f4123b0adb2a10dd097a806d6cd28b71





[CTYP-5] Support keyword arguments Created: 03/Mar/13  Updated: 25/Sep/13  Resolved: 13/Apr/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 13/Apr/13 9:33 PM ]

Supports mandatory and optional keyword arguments.





[CTYP-14] Annotation for re-find return type is too specific Created: 07/Mar/13  Updated: 25/Sep/13  Resolved: 07/Mar/13

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

Type: Enhancement Priority: Minor
Reporter: Andrew Brehaut Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

Attachments: File CTYP-14.diff    

 Description   

clojure.core/re-find returns different things depending on the regular expression used and the string it matches against. Currently core.typed annotates this as returning (Option String). However, in the presence of capture groups, it may return a vector of strings, so the current annotation is too specific.

Additionally, clojure.core/re-groups is not annotated, and uses the same return type as clojure.core/re-find.



 Comments   
Comment by Andrew Brehaut [ 07/Mar/13 9:10 PM ]

This patch (CTYP-14.diff 07/Mar/13 9:10 PM) should extend the annotations to cover all return types.

Comment by Ambrose Bonnaire-Sergeant [ 07/Mar/13 9:21 PM ]

Merged.





[CTYP-3] Support Strings as Seqables Created: 03/Mar/13  Updated: 25/Sep/13  Resolved: 08/Mar/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None





[CTYP-10] Support Clojure records Created: 03/Mar/13  Updated: 25/Sep/13  Resolved: 28/Aug/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Seems like HMaps + Datatypes, except for weird `dissoc` behaviour of losing type when dissocing all of the base keys.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 07/Apr/13 9:21 PM ]

0.1.12 adds `ann-record` and `ann-precord`, support for checking `defrecord` and some `assoc` forms.

Still need to work out how it interacts with other operations (eg. dissoc, merge).

Comment by Ambrose Bonnaire-Sergeant [ 28/Aug/13 8:10 AM ]

All destructuring forms now work with records. Going to ignore dissoc and merge for now.





[CTYP-25] Mark unannotated vars Created: 26/Mar/13  Updated: 25/Sep/13  Resolved: 09/Apr/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 1
Labels: None


 Description   

Instead of using tc-ignore, provide `ann-unchecked` to signify we should skip certain vars when type checking.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Apr/13 1:17 AM ]

Added :nocheck metadata to `ann`. Print warnings if a var is marked as checked, but no definition found. Ignore `def` forms marked as nocheck.





[CTYP-1] Support Java Generics Created: 03/Mar/13  Updated: 25/Sep/13  Resolved: 26/Jun/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Declined Votes: 0
Labels: None


 Description   

Support Java Generics

https://gist.github.com/MichaelBlume/3c0a917e0ab665c75d26

Existential types might be an issue.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 26/Jun/13 4:55 AM ]

Probably not worth the effort for now.





[CTYP-22] typechecking fails on fn calls in map vals Created: 24/Mar/13  Updated: 25/Sep/13  Resolved: 25/Mar/13

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

Type: Defect Priority: Minor
Reporter: Allen Rohner Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   
(defn foo [str] (keyword str))
(ann foo (Fn [String -> Keyword]))

user> (typed/ann foo (Fn [String -> Keyword]))
[user/foo (Fn [java.lang.String -> clojure.lang.Keyword])]
user> (typed/cf {:bar (foo "a")})
IllegalArgumentException No method in multimethod 'unparse-type*' for dispatch value: null  clojure.lang.MultiFn.getFn (MultiFn.java:121)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 25/Mar/13 3:02 AM ]

Thanks for the report. Looks like it's just some bogus error handling.

https://github.com/clojure/core.typed/commit/8571e0197ea5a2d3534bc8c3bb553ef74cbb1c34

Fixed.

Comment by Ambrose Bonnaire-Sergeant [ 25/Mar/13 4:14 AM ]

I'll try again.. https://github.com/clojure/core.typed/commit/20f5826dd6dc027063fb5c02adc10a65603b6280





[CTYP-38] Core.typed doesn't understand inner class syntax inside non-nil-return Created: 30/Aug/13  Updated: 25/Sep/13  Resolved: 09/Sep/13

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

Type: Defect Priority: Minor
Reporter: Max Gonzih Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug


 Description   

Following code snippet illustrates that non-nil-return call has no effect on recipient-type-to function.
Core.typed still assumes that Message$RecipientType/TO can return nil.

(non-nil-return javax.mail.Message$RecipientType/TO :all)

(ann recipient-type-to [-> Message$RecipientType])
(defn ^Message$RecipientType recipient-type-to []
  (Message$RecipientType/TO))

(comment
  Type mismatch:
  Expected:       (Fn [-> Message$RecipientType])
  Actual:         (Fn [-> (U Message$RecipientType nil)]))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Sep/13 3:45 AM ]

This is not an issue with inner class syntax.

This is rather about nilable fields. TO here is a static field, nilable-param only takes methods.

core.typed doesn't yet support overriding fields.

Comment by Ambrose Bonnaire-Sergeant [ 09/Sep/13 3:47 AM ]

Related: http://dev.clojure.org/jira/browse/CTYP-50





[CTYP-28] Examples of how to type futures Created: 23/Jul/13  Updated: 25/Sep/13  Resolved: 28/Aug/13

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

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


 Description   

It would be greatly appreciated if there were a few examples of how to use core.typed for futures.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 28/Aug/13 9:00 AM ]

Fixed https://github.com/clojure/core.typed/commit/2c680c825c2a946f78f6ceccc4245bfbc912c4c1#L1R1860





[CTYP-20] Missing :require of clojure.main? Created: 20/Mar/13  Updated: 25/Sep/13  Resolved: 25/Mar/13

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

Type: Defect Priority: Minor
Reporter: Mike Anderson Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug


 Description   

Affects version 0.1.8 (but version isn't listed as a valid version in JIRA)

clojure.core.typed refers to clojure.main/repl (line 725 in master)

However clojure.main is not required by the clojure.core.typed namespace, so you get an error if clojure.main has not already been loaded. This can happen in various circumstances, e.g. running "mvn test"

Code to reproduce / fix:

(ns some.namespace
(:require [clojure.main]) ;; this line is needed to avoid an error
(:require [clojure.core.typed :refer [ann inst cf fn> pfn> check-ns ann-form]]))



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 25/Mar/13 3:05 AM ]

Thanks for the report, fixed.

https://github.com/clojure/core.typed/commit/59f4f5b216a45c2ace5dfbe088dc10796ad565b0





[CTYP-4] Support complex multimethods Created: 03/Mar/13  Updated: 25/Sep/13  Resolved: 28/Aug/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Currently only single dispatch multimethods are supported.

Multiple dispatch should also be supported.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 28/Aug/13 8:11 AM ]

Multiple dispatch works well as of 0.1.25-SNAPSHOT.





[CTYP-33] A var of containing a function should be a subtype of the function Created: 07/Aug/13  Updated: 25/Sep/13  Resolved: 28/Aug/13

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

Type: Enhancement Priority: Minor
Reporter: Timo Mihaljov Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Vars implement IFn by delegating to the function they contain. Thus a var is a valid value anywhere its contained function is valid.

Currently core.typed does not allow treating vars as functions:

(t/cf + [Number * -> Number])
;= (Fn [Number * -> Number])

(t/cf #'+ [Number * -> Number])
; Type Error (user:1:1) Expected type: (Fn [Number * -> Number])
; Actual: Var
; in: (var clojure.core/+)
;
;
; Type Error (user:1:1) Expected type: (Fn [Number * -> Number])
; Actual: Var
; in: (var clojure.core/+)
;
;
; ExceptionInfo Type Checker: Found 2 errors  clojure.core/ex-info (core.clj:4327)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 28/Aug/13 8:42 AM ]

Fixed https://github.com/clojure/core.typed/commit/2dd93b6946dbeb3b6741c44f0374cd580919b3ef#L3R1855





[CTYP-6] Infer more methods Created: 03/Mar/13  Updated: 25/Sep/13  Resolved: 03/Sep/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Declined Votes: 0
Labels: None


 Description   

If the Compiler doesn't provide us with an expected method/field, we currently give up. We can do better than this.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 03/Sep/13 11:36 AM ]

I think it's better to require the user to be explicit here. Perhaps a better idea is to suggest which type hints to place, and where.





[CTYP-41] Update docstrings for check-ns and cf to make proper usage explicit (REPL only for check-ns, no recursive use for cf) Created: 03/Sep/13  Updated: 25/Sep/13  Resolved: 03/Sep/13

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

Type: Enhancement Priority: Minor
Reporter: Ethan Sherbondy Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

When I first tried to use check-ns, I assumed incorrectly that it could be called from within a source file.
I was led to believe this from the example here: https://github.com/clojure/core.typed/wiki/User-Guide#var-warnings
Where (check-ns), although being commented out, is included in the code of a snippet which looks like a file.

Tweaking the docstring for check-ns to state that the function is intended for use from the REPL would probably reduce noobie-flailing.

Also a friendly reminder for you to update the docstring for cf to indicate that it should not be called recursively.

Thanks!



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 03/Sep/13 11:34 AM ]

Fixed in master.

Documentation fix: https://github.com/clojure/core.typed/commit/343d372ab9e21499a1471f04fb52d25f5d527408

User guide fix: https://github.com/clojure/core.typed/wiki/_compare/36fab1f123d4ce10c287e4956b2a482ae6df68cc...b7be5ee7fdaa68a51f3d1cc14aa443cbbcb28768





[CTYP-45] Confusing error message when using clojure.core/defprotocol instead of clojure.core.typed/defprotocol> Created: 04/Sep/13  Updated: 25/Sep/13  Resolved: 08/Sep/13

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

Type: Defect Priority: Minor
Reporter: Timo Mihaljov Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

Clojure 1.5, core.typed 0.2.2



 Description   

Type checking a namespace using clojure.core/defprotocol instead of clojure.core.typed/defprotocol> results in the following error:

Exception in thread "main" java.lang.AssertionError: Assert failed: 4: Cannot set! (U nil clojure.lang.MethodImplCache) to Any

Form:
        (set! (. f__5866__auto__ __methodImplCache) cache__5865__auto__)
(sub/subtype? (-> cval expr-type ret-t) (-> ctarget expr-type ret-t))

Here's a minimal project demonstrating the problem: https://github.com/noidi/core.typed-record-problem

Although the user guide mentions defprotocol>, it's very easy to run into this error by accident, and the error message does not give the user any hints as to what might be wrong. In the long term it would be best if core.typed could deal with clojure.core/defprotocol. As a stopgap measure, maybe core.typed could detect this error and instruct the user to use clojure.core.typed/defprotocol> instead?



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 08/Sep/13 6:05 AM ]

The first error is now about the protocol var being unannotated, which I'm happy enough should give people hints as to how to fix the error.

https://gist.github.com/frenchy64/6483863

Fixed with: https://github.com/clojure/core.typed/commit/f65a3d20ac35c955c1014c79c72167c480f9509d





[CTYP-90] Add assoc at the type level Created: 21/Oct/13  Updated: 21/Oct/13  Resolved: 21/Oct/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 21/Oct/13 8:00 AM ]

Resolved: https://github.com/clojure/core.typed/commit/0c97ef80b7a3aaef72a7975f3164466323feee62





[CTYP-89] Add rest args to HVector Created: 20/Oct/13  Updated: 21/Oct/13  Resolved: 21/Oct/13

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 21/Oct/13 9:15 AM ]

Resolved: https://github.com/clojure/core.typed/commit/4e4a2697a9de3153fc69f1ab58ca9613127bcd0f





[CTYP-86] Annotation for clojure.core.interleave is wrong. Created: 09/Oct/13  Updated: 18/Nov/13  Resolved: 18/Nov/13

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

Type: Defect Priority: Minor
Reporter: Albrecht Schmidt Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Annotation for interleave accepts only one arg, but interleave actual needs two or more.
https://github.com/clojure/core.typed/blob/master/src/main/clojure/clojure/core/typed/base_env.clj#L984
maybe something like: (All [x] [(Option (Seqable x)) (Option (Seqable x)) * -> (Seq x)]) (thanks to nathanic @ irc)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 18/Nov/13 8:28 AM ]

Fixed https://github.com/clojure/core.typed/commit/b8c53c3c82f5b1a14222820185240d72db4e3cb7





[CTYP-103] Emacs plugin for Typed Clojure Created: 11/Feb/14  Updated: 12/Feb/14  Resolved: 12/Feb/14

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Should have similar features to https://github.com/typedclojure/vim-typedclojure

Right now Typed Clojure just spews out type errors, it would be nice if they were hyperlinked to the sources. Most of the work is already done, this is mostly all it took for the Vim plugin: https://github.com/typedclojure/vim-typedclojure/blob/master/plugin/typedclojure.vim#L53

Also some bindings for common refactorings like wrapping in `ann-form` or making an
`ann` for directly above a `def`.

A binding for `cf` (type check current form) would be good.






[CTYP-104] Light Table Plugin Created: 13/Feb/14  Updated: 18/Feb/14  Resolved: 18/Feb/14

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Should be similar to the vim and emacs plugins.

Should type check the current namespace with this code and match up the line/col/source positions in the actual Light Table window, and display the type error message above/below it (whatever is more common in LT).

Also "check-form" should be a command, that type checks the current form with clojure.core.typed/check-form-info.

2 refactorings should be included:

ann-form - wrap current form in an clojure.core.typed/ann-form (which could be qualified by an alias) and leave the cursor on the second argument. If it's possible to add a default to the second argument, it should be `Any`.

eg. my-form
-> (t/ann-form my-form |Any)
; where | is the current cursor

ann-var - bring out the var on the current cursor into an `ann` into the top-level form above the current form.

  • if the var is from another namespace than the current, it should be fully qualified and prefixed with ^:no-check
    eg. n/another-var => (t/ann ^:no-check long-another-ns/another-var Any)
  • otherwise the second argument to `ann` should be unqualified

eg. my-var
-> (t/ann my-var |Any)



 Comments   
Comment by Marco Munizaga [ 16/Feb/14 9:39 PM ]

I'll tackle this problem this week





[CTYP-115] core library annotation Created: 07/Mar/14  Updated: 09/Mar/14  Resolved: 09/Mar/14

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

Type: Enhancement Priority: Minor
Reporter: Di Xu Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

Attachments: File annotation-v3.diff    
Patch: Code

 Description   

add some core library annotation to get familiar with the whole process of development



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 07/Mar/14 8:01 AM ]

You can use macros to generate var annotations; see how clojure.core/count does it.

Read only Agents should be: (Agent2 Nothing Any).

Comment by Di Xu [ 07/Mar/14 9:36 AM ]

Then, what should await1 be annotated? [(Agent2 Nothing Any) -> (Agent2 Nothing Any)]? But result type should be writable.

Comment by Ambrose Bonnaire-Sergeant [ 08/Mar/14 8:45 AM ]

Is await1 even a public function? Weird, it has no docstring.

I think it should be:

(All [w r] [(Agent2 w r) -> (Agent2 w r)])

Comment by Di Xu [ 08/Mar/14 8:13 PM ]

Ah, I forget about polymorphic function, sorry.

Comment by Ambrose Bonnaire-Sergeant [ 09/Mar/14 11:11 AM ]

Merged https://github.com/clojure/core.typed/commit/aab9129e2bc21516343bf181c7132ff5a6c4b920





[CTYP-118] Support clojure.core/cast Created: 13/Mar/14  Updated: 14/Mar/14  Resolved: 14/Mar/14

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

Attachments: File ann-cast.diff     File ann-cast-v2.diff     File ann-cast-v3.diff     File ann-cast-v4.diff    

 Comments   
Comment by Di Xu [ 13/Mar/14 6:23 AM ]

annotate cast using add-invoke-special-method

Comment by Ambrose Bonnaire-Sergeant [ 13/Mar/14 6:36 AM ]

The invoke-special case should be more lenient.

If the first argument is a literal class, then it can be special cased, otherwise return :default.

Use RClass-of-with-unknown-params like in :instance-of.

Please add some tests in clojure.core.typed.test.core, testing the special case and the normal case.

Comment by Di Xu [ 13/Mar/14 6:56 AM ]

Well, I'm confused, I only aware of the literal class could be the first argument. could you give me some example of nonliteral class argument?

Comment by Ambrose Bonnaire-Sergeant [ 13/Mar/14 7:03 AM ]

I mean this is still type correct:

(ann foo [Class Any -> Any])
(defn foo [c a]
(cast c a))

Comment by Ambrose Bonnaire-Sergeant [ 13/Mar/14 9:15 AM ]

I wonder if `cast` should make an intersection of the original type and the casted type.

(cast String "a") => (I String (Value "a"))

Perhaps that's more useful. Just implement the simple RClass return type for now.

Instead of testing (-> args first :val), you should inspect the type of
(-> (check (first args)) expr-type ret-t c/fully-resolve-type).

If it's a Value type and the :val field is a `class?`, then it's a special case.

Comment by Di Xu [ 14/Mar/14 2:10 AM ]

thanks for the detailed solution. I'm still not very familiar with its internal type

Comment by Ambrose Bonnaire-Sergeant [ 14/Mar/14 2:53 AM ]

To make an intersection, use c/In.

Also need a test for (cast (ann-form Class Class) :any)

Make a failing test like this:

(is (u/top-level-error-thrown?
(cf (fn [] (cast "a" "a"))))

Please add a few failing tests.

Comment by Di Xu [ 14/Mar/14 3:39 AM ]

you mean (cast (ann-form Class Class) (class :any))?

Comment by Ambrose Bonnaire-Sergeant [ 14/Mar/14 4:07 AM ]

Ah yes.

Comment by Di Xu [ 14/Mar/14 5:43 AM ]

added

Comment by Ambrose Bonnaire-Sergeant [ 14/Mar/14 7:03 AM ]

Merged.

For future reference, throws-tc-error? can catch int-errors.

Thanks!

Comment by Di Xu [ 14/Mar/14 8:04 AM ]

got it.





[CTYP-121] Type annotation for clojure.core/ex-info forbids nil message argument Created: 14/Mar/14  Updated: 18/Mar/14  Resolved: 14/Mar/14

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

Type: Defect Priority: Minor
Reporter: Gordon Syme Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

The bug here is either in Clojure itself or core.typed, they don't agree on the arguments to clojure.core/ex-info.
I'm reporting it here because I have to pick somewhere

clojure.lang.ExceptionInfo allows null for the exception message, clojure.core/ex-info just passes the arguments straight to the ExceptionInfo constructor so it allows nil for the exception message.

I think the correct type annotation in core/typed/base_env.clj (given how ex-info is implemented) should be:

(ann clojure.core/ex-info (Fn [(Option String) (Map Any Any) -> clojure.lang.ExceptionInfo]
                              [(Option String) (Map Any Any) (Option Throwable) -> clojure.lang.ExceptionInfo]))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 14/Mar/14 7:59 AM ]

Fixed https://github.com/clojure/core.typed/commit/926c5a140ecbe33d9ebb5efb37c98d87209121f3

Comment by Gordon Syme [ 18/Mar/14 6:24 AM ]

Awesome, thanks Ambrose





[CTYP-122] annotation fails on recur Created: 16/Mar/14  Updated: 23/Mar/14  Resolved: 16/Mar/14

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

Type: Defect Priority: Minor
Reporter: Christian S Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug
Environment:

Mac OS X, clojure 1.5.1, Oracle JDK 1.7.0_45



 Description   

The following test case fails on check-ns. The issue seems to be the use of recur. The test case is modelled after clojure.core/<

huhu.clj
(ns huhu (:require [clojure.core.typed :refer :all]))
  (ann testcase [Number Number * -> boolean])
  (defn testcase
    ([x] true)
    ([x y] false)
    ([x y & more]
     (if (testcase x y)
       (if (next more)
         (recur y (first more) (next more))
         (testcase y (first more)))
       false)))

This is the result of check-ns:

(check-ns)
Start collecting huhu
Finished collecting huhu
Collected 1 namespaces in 26.58 msecs
Start checking huhu
AssertionError Assert failed: (AnyType? t)  clojure.core.typed.type-rep/ret (type_rep.clj:825)

If a recursive call instead of recur would be used it works. This is not a workaround to be applicable in every case.



 Comments   
Comment by Christian S [ 16/Mar/14 8:01 AM ]

clojure.core.typed version is [org.clojure/core.typed "0.2.37"]

Comment by Ambrose Bonnaire-Sergeant [ 16/Mar/14 8:38 AM ]

Fixed in 0.2.38-20140316.133526-3





[CTYP-127] Incorrect type inferred for key lookups from bounded polymorphic types Created: 24/Mar/14  Updated: 24/Mar/14  Resolved: 24/Mar/14

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

Type: Enhancement Priority: Minor
Reporter: Timo Mihaljov Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

When a polymorphic type x has an upper bound of U, and U is an HMap or a record, I'd expect key lookups from x have the same type as key lookups from U. Currently they are inferred as Any.

(t/def-alias U (HMap :mandatory {:foo Number}))
(t/ann foo (All [[x :< U]] [x -> Number]))
(defn foo [x]
  (:foo x))

Type Error (...) Type mismatch:

Expected: 	java.lang.Number

Actual: 	Any
in: (:foo x)

Explicitly upcasting x to U with ann-form fixes the inferred type.

(t/def-alias U (HMap :mandatory {:foo Number}))
(t/ann foo (All [[x :< U]] [x -> Number]))
(defn foo [x]
  (:foo (t/ann-form x U)))

Both HMap and record bounds exhibit the same problem.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 24/Mar/14 3:13 AM ]

Fixed in 0.2.40 with https://github.com/clojure/core.typed/commit/514abf5da7a7c5b4a7ec7de6a9b2af6c6e941d6a





[CTYP-126] add support for user-defined dotted polymorphic function, and fix a bug Created: 23/Mar/14  Updated: 25/Mar/14  Resolved: 25/Mar/14

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

Type: Enhancement Priority: Minor
Reporter: Di Xu Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

Attachments: File polydot.diff     File polydot-v2.diff     File polydot-v3.diff     File polydot-v4.diff    

 Description   

previously, user-defined function couldn't be annotate as dotted polymorphic function, this patch make this possible. Also, while writing the test case, I found that the code assume function's requried-params is more than or equal to the dom of function's type, but not less like `(fn [& y] (if (empty? y) nil (first y))) (All [x y ...] [x y ... y -> (U x nil)])`, so we may skip the function type `x`, I fixed this by changing the interface of check-fn-method1-rest-type from `(fn [rest drest kws]` to `(fn [remain-dom rest drest kws]`.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 23/Mar/14 11:41 AM ]

Prefer `drop` over `nthrest` (it's lazy).

Instead of using a HVec (which in itself isn't accurate, the rest argument is a nilable non-empty seq), just use the same approach as previous, except take the union of the remaining dom and the dotted pretype.

Return something like:

(c/Un
  r/-nil
  (r/TApp-maker (r/Name-maker 'clojure.core.typed/NonEmptySeq)
  [(apply c/Un (or rest (.pre-type ^DottedPretype drest)) remain-dom)]))

Update the tests to reflect we're being a little less accurate here.

Great work!

Comment by Ambrose Bonnaire-Sergeant [ 23/Mar/14 12:34 PM ]

gfredericks is having a related issue https://www.refheap.com/63657

Comment by Di Xu [ 23/Mar/14 11:07 PM ]

I think

(apply c/Un (or rest (.pre-type ^DottedPretype drest)) remain-dom)

is not accurate enough, my patch generate type like

(U [x] [x y] [x y z] nil)

so that the `count` will filter out some type. I want to use `HeterogeneousSeq`, but it seems `first` don't recognize it.

Comment by Ambrose Bonnaire-Sergeant [ 24/Mar/14 4:35 AM ]

I think your approach throws away the rest and drest information which is an issue.

HVec supports rest/drest, but HSeq does not. You can add support by copying how HeterogeneousVector does it.

Also we should introduce a HSequential that just extends clojure.lang.Sequential. Then we can use it to abstract over HVec, HSeq and HList, and use it in the first argument of `first`, rather than hard-coding HVec.

Which reminds me, clojure.lang.ISeq isn't sequential, so we need to ensure HSeq is sequential.

user=> (isa? clojure.lang.ASeq clojure.lang.Sequential)
true
user=> (isa? clojure.lang.ISeq clojure.lang.Sequential)
false

So we need to:

  • add support for rest/drest in HSeq
  • implement HSequential (with rest/drest support)
  • add cases in subtype/cs-gen for HSequential (on the right)
  • use HSequential in types like `first`
  • ensure we don't throw away rest/drest in check-fn-method1-rest-type
Comment by Di Xu [ 24/Mar/14 6:43 AM ]

well, updated patch according to your first comment, leave the improvement of accuracy for future

Comment by Ambrose Bonnaire-Sergeant [ 24/Mar/14 8:43 AM ]

Please pull the latest master, doesn't seem to patch cleanly.

A few things before I merge:

  • add ((some-fn nil? r/DottedPretype?) drest) to the FnResult contracts
  • I'm pretty sure the code you commented out is incorrect. It doesn't use the rest/drest type properly. better just to remove it and just leave a comment referencing this ticket. We can always look back at the ticket.
  • add (every? r/Type? remain-dom) to the :pre of check-fn-method1-rest-type
  • just pass (drop (count required-params) dom) as the first argument to check-fn-method1-rest-type. Otherwise we're traversing dom twice.
Comment by Di Xu [ 24/Mar/14 10:58 AM ]

done, but assume you mean

((some-fn nil? (u/hvector-c? symbol? r/DottedPretype?)) drest)

by

((some-fn nil? r/DottedPretype?) drest)
Comment by Ambrose Bonnaire-Sergeant [ 24/Mar/14 11:10 AM ]

I actually meant on the RecurTarget contract, you've put the correct contract on FnResult.

Comment by Di Xu [ 24/Mar/14 9:31 PM ]

done

Comment by Ambrose Bonnaire-Sergeant [ 25/Mar/14 2:30 PM ]

Merged https://github.com/clojure/core.typed/commit/b9029ab0d3b4f2e7db4766f35e316dfd380e541e





[CTYP-132] typechecker fails when checking a Protocol whose method gets called using dot notation Created: 12/Apr/14  Updated: 13/Apr/14  Resolved: 13/Apr/14

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

Type: Defect Priority: Minor
Reporter: Daniel Ziltener Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug
Environment:

Clojure 1.6.0, core.typed 0.2.44



 Description   

The error message is

No method in multimethod 'check' for dispatch value: :host-interop

The following is a minimal test case which fails:

core.clj
(ns core-typed-bug.core
    (:require [clojure.core.typed :refer :all]))
 
(defprotocol> ITypedTest
    (get-data [this]))
 
(defn> testfn :- Any
    [asdf :- Keyword, in :- ITypedTest]
    (.get-data in))

It works, however, when calling (get-data in) instead of (.get-data in).



 Comments   
Comment by Nicola Mometto [ 12/Apr/14 7:13 PM ]

tools.analyzer.jvm returns a :host-interop node when, like in this case, it encounters an interop form of the form (.foo bar) and can't determine whether it's a no-arg method call or a field-access.

I don't know enough about core.typed internals but it looks like there should be an add-check-method for :host-interop that behaves like check methods for :instance-field/:instance-call that resolve to runtime reflection (not :validated)

Comment by Ambrose Bonnaire-Sergeant [ 13/Apr/14 12:44 AM ]

Thanks Daniel & Nicola, fixed https://github.com/clojure/core.typed/commit/fa22d52d8e9855ebbaf2593ec5e848ba714b25fc





[CTYP-56] Support 3 argument isa? Created: 13/Sep/13  Updated: 23/Sep/13  Resolved: 23/Sep/13

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

Type: Enhancement Priority: Trivial
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Does not need special type for occurrence typing.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 23/Sep/13 11:32 AM ]

Fixed: https://github.com/clojure/core.typed/commit/f73cdc5df8158ed530e275bd0e5452d8cb604a13

Will be included in 0.2.11





[CTYP-79] Cannot assoc optional HMap keys Created: 02/Oct/13  Updated: 09/Oct/13  Resolved: 09/Oct/13

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

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


 Description   

https://groups.google.com/d/msg/clojure-core-typed/TxfeEaTnFlM/bX4HRJW3xzIJ



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Oct/13 8:13 PM ]

Fixed https://github.com/clojure/core.typed/commit/ebebb1dd2d4fd1453086b5692aec07b718c63297





[CTYP-92] Implement a defn> macro Created: 06/Nov/13  Updated: 08/Nov/13  Resolved: 08/Nov/13

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

Type: Enhancement Priority: Trivial
Reporter: Reid McKenzie Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: patch

Attachments: Text File typed.patch    
Patch: Code and Test

 Description   

Implement a defn> macro which wraps fn> and def, providing concise function declaration and annotation.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 08/Nov/13 9:54 AM ]

Merged, included in 0.2.17.





[CTYP-94] Annotation for derive has wrong return type Created: 10/Nov/13  Updated: 11/Nov/13  Resolved: 11/Nov/13

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

Type: Defect Priority: Trivial
Reporter: Hugo Duncan Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

The base annotation for `derive` declares a return value of Any, while it actually returns a `Hierarchy`.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 11/Nov/13 7:24 AM ]

Fixed in 0.2.19

https://github.com/clojure/core.typed/commit/da457a8f9aa74f5b4631db961e2550633cf77a68





[CTYP-125] delay is not annotated / no "Delay" equiv to Future / Promise Created: 22/Mar/14  Updated: 23/Mar/14  Resolved: 23/Mar/14

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

Type: Enhancement Priority: Trivial
Reporter: Sean Corfield Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Ambrose suggested: (ann ^:no-check clojure.core/delay (All [x] [x -> (clojure.lang.Delay x)]))

Does there also need to be an alias along the lines of Future and Promise (in core.typed) for Delay?



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 23/Mar/14 1:46 PM ]

I forgot `delay` is a macro, so I added a Delay alias which should be sufficient.

https://github.com/clojure/core.typed/commit/143ab9574ec90e83e8195fa1031ba295b85d0748

Comment by Sean Corfield [ 23/Mar/14 2:15 PM ]

Thank you!





Generated at Sun Apr 20 03:54:57 CDT 2014 using JIRA 4.4#649-r158309.