<< Back to previous view

[CTYP-272] check-ns: Assert failed: (r/Type? t) Created: 25/Aug/15  Updated: 25/Aug/15

Status: Open
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: 0.3.10, 0.3.11
Fix Version/s: 0.3.12

Type: Defect Priority: Major
Reporter: Connor Clark Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: bug
Environment:

Java 8, Clojure 1.7, OS X 10.10.3


Attachments: File bugoutput     File jim.clj     File project.clj    

 Description   

The presence of the function

(defn foo
[x y]
(pos? (rem x y)))

in a namespace causes an assert error when check-ns is called on it.

Attached is the full output of lein typed check, and the full code for a lein project that demonstrates the bug. This only occurs in 0.3.11 and 0.3.10.






[CTYP-270] "Method core too large!" with protocols (more than 38 functions in the protocol) Created: 17/Aug/15  Updated: 17/Aug/15

Status: Open
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: 0.3.11
Fix Version/s: None

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


 Description   

You should be able to get the error with lein typed check on this.

https://gist.github.com/freakhill/2df1117738362d602672



 Comments   
Comment by Johan Gall [ 17/Aug/15 11:46 PM ]

"Method coDe too large!"

more than 39 functions





[CTYP-260] Add Queue and BlockingQueue to altered classes Created: 23/Jul/15  Updated: 27/Aug/15

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

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

Attachments: Text File alter-queues.patch    
Patch: Code

 Description   

Add java.util.Queue and java.util.concurrent.BlockingQueue to the list of special cases that allows them to be annotated with a type parameter.

Discussion: https://groups.google.com/forum/#!topic/clojure-core-typed/cgJlGriJ4OY



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 24/Jul/15 1:51 AM ]

I'm not sure we need to annotate java.util.Queue to get what you want.

We should already be able to upcast a Queue to a (Collection Any), and therefore
a (Seqable Any).

If you want to track the type of the queue, you might want to use an intersection
like (I Queue (Seqable Num)).

So try replacing (Queue Num) with (I Queue (Seqable Num)) and see if that covers
your use cases.

Comment by Mark Feeney [ 26/Jul/15 11:35 PM ]

Hm, I think this may work.

With this sort of method, is it possible to tell the checker what element type is in the collection at create time? e.g.

(t/cf (java.util.LinkedList. [1 2 3]) (t/I java.util.Queue (t/Seqable t/Any))) ; checks, but t/Any
(t/cf (java.util.LinkedList. [1 2 3]) (t/I java.util.Queue (t/Seqable t/Num))) ; doesn't check, but desirable t/Num

i.e. I can create a fn expecting an (I Queue (Seqable Num)), but I'm not sure I see how to create one to pass to it.

Comment by Ambrose Bonnaire-Sergeant [ 27/Jul/15 3:55 AM ]

This is the same situation as your patch. Only unchecked code can introduce a Queue that
holds anything other than Any.

Comment by Mark Feeney [ 27/Aug/15 8:26 PM ]

I think I can work around my original issues with the intersection type approach. Happy to close this unless you think the enhancement is still worthwhile.





[CTYP-241] Let-aliased variables of plain Map lookups should update original map Created: 26/Jun/15  Updated: 22/Jul/15

Status: Open
Project: core.typed
Component/s: Core type system
Affects Version/s: None
Fix Version/s: 0.3.x

Type: Defect Priority: Major
Reporter: Mark Feeney Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: regression
Environment:

After commit https://github.com/clojure/core.typed/commit/960802



 Description   

Problem

Let-aliasing means we completely rely on the original binding's
type to find the type for locals derived from lookups on it. If
occurrence typing doesn't update the original binding, then even
very simple control flow does not register.

For example, in core.typed 0.3.7, the following code registers
e as an alias of (Key :foo)m.

(fn [m :- (Map Any Str)] :- String
  (let [e (:foo m)]
    (if e e "asdf")))
;;        ^
;;  Expected Str, actual (U nil Str)

e contains the correct propositions and object, however
update ignores propositions that update non-HMap types.

So in the test position, m is still of type (Map Any Str), which means path-type
infers Any for its aliased object (above). (Note: path-type should infer slightly better
types here, eg., this should return (U nil Str)).

Solution

The update case for keyword invocations on non-HMaps
need to intersect its known HMap type.

We now make it an error to assign an object to the result of looking up
a possibly-mutable map. ie.,

(fn [a :- Any] (:foo a))

has no object.

Correspondingly, update will throw an error if told to update via a keyword lookup
on a map type that is not a subtype of (U nil (Map Any Any)).

We cannot have objects that might be wrong — the formalism asserts that in

G |- e : t ; v+ | v- ; o}}, where G |- p and p |- e || v, that o = empty, or p(o) = v.

That means looking up an object o of an expression e must always
result in exactly its evaluation v. If we gave an object to

(fn [a :- Any] (:foo a))

that means two invocations of

((fn [a :- Any] (:foo a)) m)

must return exactly the same value — for a mutable m this is clearly false.

Interestingly, this has worked fine in practice until let-aliasing, by compensating
in the update function. We basically only update types that are immutable, checked
at the last minute in update.

Briefly, to handle this idea of "temporarily fake" objects, we probably need a predicate to validate
whether an object should be taken "seriously" as an actual, immutable, path. Then the formalism
might read:

G |- e : t ; v+ | v- ; o}}, where G |- p and p |- e || v, that o = empty, or if serious(o) then p(o) = v.

More information

Discussion here: https://groups.google.com/d/msg/clojure-core-typed/WO8dpY63N2Q/7UWBViNiIYEJ

git bisect code

(do (require '[clojure.core.typed :as t]) (t/cf (t/fn [m :- (t/Map t/Kw String)] :- String (or (:foo m) "asdf"))))

This stopped type checking after https://github.com/clojure/core.typed/commit/9608027bfaf4be268cfa12486c5ae6615d8517f1

bisect result:

9608027bfaf4be268cfa12486c5ae6615d8517f1 is the first bad commit
commit 9608027bfaf4be268cfa12486c5ae6615d8517f1
Author: Ambrose Bonnaire-Sergeant <...@gmail.com>
Date: Sat Jan 3 00:05:23 2015 +0000

enable aliasing support

Pull request:

Patch:
Commmit:
Release:



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 18/Jul/15 2:21 AM ]

Minimal failing case:

(is-tc-e (fn [m :- (Map Kw Str)] :- Str 
           (let [e (:foo m)]
             (if e e "asdf"))))
;;                 ^
;;    Expected Str, actual (U nil Str)

This happens because let-aliasing relies on path-type solely to get a type for `e` and the type is not updated sufficiently based on this control flow.

Work started here: https://github.com/typedclojure/core.typed/pull/26





[CTYP-232] Let-aliased variabled of HVec lookups should update original HVec Created: 23/Jun/15  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: None
Affects Version/s: None
Fix Version/s: 0.3.x

Type: Defect Priority: Major
Reporter: Mark Feeney Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

core.typed 0.3.7



 Description   

Discussed here: https://groups.google.com/d/msg/clojure-core-typed/njLzL8NinCc/7K9vxTZn__AJ

In both of the following cases core.typed'd thinks the HVec can contain nil, but it can't.

My original example:

(t/cf
  (t/fn [[x y] :- '[String (t/Option Number)]] :- (t/U '[String] '[String Number])
    ;;(if (number? y) ;; works!
    ;;(if-not (nil? y) ;; doesn't work
    (if y ;; doesn't work
      [x y]
      [x])))

Type Error (:30:5) Type mismatch:

Expected:       (t/U (t/HVec [String]) (t/HVec [String Number]))

Actual:         (t/HVec [String (t/U nil Number)])
in: [x y]

Simpler example that might be the same thing (from Ambrose):

(fn [v :- '[(U nil Num)]] :- Num
  (if (first v)
    (first v)
    1))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 24/Jun/15 12:45 AM ]

WIP here https://github.com/typedclojure/core.typed/pull/3





[CTYP-229] Checker slows development in rechecking dependent namespaces Created: 21/Jun/15  Updated: 22/Jun/15

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

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


 Description   

`check-ns` is quite aggressive in checking the dependencies of the namespaces explicitly passed in, somewhat unexpectedly. This significantly slows down development when attempting to type-check a namespace with large number of dependencies. Is there an option to type-check a namespace without its transitive dependencies?

Also, I noticed that `check-ns-and-deps` could be using an incorrect criteria for checking dependencies. My local patch is the following: https://github.com/clojure/core.typed/commit/78937733f7db750e94b1a142f3c64fa37bc7a255 . Not sure how to write a test for it though.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 22/Jun/15 12:47 AM ]

The current behaviour is intentional, with the intention that `check-ns` is ruthlessly immune to REPL state.

Selectively ignoring dependencies is perhaps not desirable feature. It would certainly speed up REPL development because it skips a lot of static type checking.

I think what we really want is what `clojure.core/load` does for transitive dependencies: only check them once in the same session. This way, it speeds up REPL development. One off type checks still need to check everything though.

Comment by Ambrose Bonnaire-Sergeant [ 22/Jun/15 10:24 AM ]

Prototype of `check-ns` that caches its transitive dependencies is at `0.3.0-20150622.124924-21`.

`check-ns` now takes a keyword arg `:clean` that acts like the old `check-ns`.





[CTYP-228] Type signature for sort is incorrect - never returns nil Created: 19/Jun/15  Updated: 22/Jun/15

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

Type: Defect Priority: Major
Reporter: Marc O'Morain Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None

Patch: Code

 Description   

https://github.com/clojure/core.typed/pull/13

Patch: https://patch-diff.githubusercontent.com/raw/clojure/core.typed/pull/13.patch



 Comments   
Comment by Marc O'Morain [ 19/Jun/15 5:26 AM ]

Thinking more about this, the type signature for the comparator is incorrect too, since a comparator function can be a predicate and clojure will deal with the details of implementing the Java comparator interface (returning an integer).

Comment by Ambrose Bonnaire-Sergeant [ 19/Jun/15 5:34 AM ]

There is a reason `nil` is in the return type. In the implementation, the hypothetical situation where a mutable `coll` argument changes from length < 0 to length 0 between these two lines, it will return `nil`.

https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2981-L2982

I'm actually not sure if this is even possible, but it's not robust from `nil` IMO.

As for the comparator, what is the correct type?

Comment by Marc O'Morain [ 19/Jun/15 6:04 AM ]

For the comparator, as far as I can tell this is the code that is called when a function that is not a comparator is passed to sort:

https://github.com/clojure/clojure/blob/41af6b24dd5be8bd62dc2b463bc53b55e18cd1e5/src/jvm/clojure/lang/AFunction.java#L46

functional-kats.core=> (sort = (range 10))
(0 1 2 3 4 5 6 7 8 9)
functional-kats.core=> (sort (comp not =) (range 10))
(9 8 7 6 5 4 3 2 1 0)
functional-kats.core=> (sort > (range 10))
(9 8 7 6 5 4 3 2 1 0)
functional-kats.core=> (sort < (range 10))

So the comparator is a function [x x -> (U AnyInteger Boolean)] (I'm not certain though - this is my first time ever to use core.typed in anger).

Comment by Marc O'Morain [ 19/Jun/15 6:07 AM ]

It looks like there is no constraint on the comparator returning an integer, either:

functional-kats.core=> (sort (constantly 1.3) (range 10))
(0 1 2 3 4 5 6 7 8 9)

So maybe [x x -> (U Num Boolean)] ?

Comment by Ambrose Bonnaire-Sergeant [ 19/Jun/15 6:24 AM ]

I would like to know why floats and booleans work.

According to the Comparator docs, a comparator can only return a primitive int.

https://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html

Comment by Marc O'Morain [ 19/Jun/15 6:28 AM ]

It's the compare function of the AFunction.java class that is going the work:

Here is the boolean trick: https://github.com/clojure/clojure/blob/clojure-1.5.1/src/jvm/clojure/lang/AFunction.java#L51

And here is the cast from Number to int: https://github.com/clojure/clojure/blob/clojure-1.5.1/src/jvm/clojure/lang/AFunction.java#L58

Comment by Ambrose Bonnaire-Sergeant [ 19/Jun/15 6:38 AM ]

Ah interesting! It seems the real type is (U [x x -> Int] (I Comparable [x x -> (U Num Bool)])).

[x x -> Int] is basically the same as clojure.lang.IFn.

The problem with this annotation is that (fn []) is of type [-> nil], not (I Comparable [-> nil]). I'm unsure what the best thing to do here is.

Comment by Ambrose Bonnaire-Sergeant [ 19/Jun/15 6:45 AM ]

Another note: clojure.core/sort is duplicated in base_env.clj and base_env_common.clj. We should delete the base_env_common.clj version depending on the CLJS annotation, which should then live in base_env_cljs.clj.

Comment by Ambrose Bonnaire-Sergeant [ 19/Jun/15 7:00 AM ]

I think we also want to add a type parameter to Comparable. Instead of [x x -> Int] being a Comparable, it should be a (Comparable x).

Comment by Ambrose Bonnaire-Sergeant [ 19/Jun/15 7:02 AM ]

So assuming we add a type parameter, the type should be (Comparable x).

Comment by Marc O'Morain [ 19/Jun/15 7:04 AM ]

That's a good idea - there are many functions that take a comparator: sort-by, sorted-set-by, sorted-map-by, etc.

Comment by Ambrose Bonnaire-Sergeant [ 19/Jun/15 7:18 AM ]

AFunction is some weird type that is sometimes a valid Comparable.

How are you supposed to know [-> Num] in an invalid Comparable? [Any Any -> Any] ?

Ouch.

Comment by Marc O'Morain [ 19/Jun/15 11:22 AM ]

I've gone ahead and added a local annotation to our project to remove nil from the return type from {sort} – after reflection I don't think it's worth burdening every caller of {sort} with adding a nil check to the result, or infecting all client code with an (Option) type for such an unlikely occurrence.

For the sort function to return a nil, the caller would have to pass in a mutable collection and (unsafely) modify the collection while sorting. If someone is doing this they have bigger problems that type safety.

Comment by Ambrose Bonnaire-Sergeant [ 19/Jun/15 11:41 AM ]

I could imagine writing some library code in core.typed and then someone else triggering a NPE deep inside typed code; this is not supposed to be possible.

FWIW Nicola Mometto figured out a fun example of returning nil http://sprunge.us/VIFc?clj

Just a word about the philosophy of core annotations: the unchecked annotations of clojure.core must be sound, over any conveniences that might be gained. It doesn't take much to compromise all static guarantees.

This particular case, I think, is a bug in the implementation of `sort`; it should be an if-let.

Could you please share why this important to you? What functions are you using that accept () but not nil? What makes it more convenient to assume nil is impossible?

If it's only a problem in a few areas, you can convince core.typed nil is impossible with a runtime assertion. eg. (let [s (sort ..)] (assert s) s).

Comment by Marc O'Morain [ 22/Jun/15 5:00 AM ]

> This particular case, I think, is a bug in the implementation of `sort`; it should be an if-let.
That's a good point, and I agree. I'll create a new ticket to address the documentation issues with sort.

> Could you please share why this important to you? What functions are you using that accept () but not nil? What makes it more convenient to assume nil is impossible?

I'm working on adding annotations to a namespace that searches and filters files in a file-system. There are function to search the filesystem, with signatures like [String Pattern -> (Seq String)] to search a directory for files that match the given pattern. There are also functions that filter searches like [(Seq String) Pattern -> (Seq String)].

My issue is philosophical – a nil becomes infectious, I would need to change the signatures to widen the allowed types from (Seq String) to (U (nil (Seq String)) throughout the namespace and client code, or alternatively to add assertions or change calls to sort to instead call a form like (or (sort x) '()).

The more I think about it the more I realise that the issue is with sort, not the type annotations, as you point out above. I'm writing code that sorts a non-empty list and I have to deal with the fact that the result of sorting a non-empty could be nil.





[CTYP-226] Update clojure.core/get-in annotations to use polymorphic function types (similar to clojure.core/get) Created: 14/Jun/15  Updated: 14/Jun/15

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

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


 Description   

The get-in annotation is too simplistic, and should mimic the more precise annotation of clojure.core/get






[CTYP-225] Intersections of value types broken Created: 02/Jun/15  Updated: 02/Jun/15

Status: Open
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: Unresolved Votes: 0
Labels: None


 Description   

https://gist.github.com/joerupen/efb104ea81fce9d3a77d

;; Does core.type intersection not work on values?
 
(ns user-types.demo
  (:require [clojure.core.typed :as t]))
 
(t/defalias week-days "mon-fri"
  (t/U (t/Val :mon) (t/Val :tue) (t/Val :wed) 
       (t/Val :thu) (t/Val :fri) ))
 
(t/defalias party-days "days with party events"
  (t/U  (t/Val :fri) (t/Val :sat)))
 
(t/defalias party-days-of-the-week "days in the week with party events"
  (t/I week-days party-days))
 
(t/defn party-during-week [x :- party-days-of-the-week] x)
 
;; then in repl
(check-ns 'user-types.demo)
 
(t/cf (u/party-during-week :wed))
;; ups, no error? only friday should be allowed
=> [(t/I u/party-days u/week-days) {:then tt, :else ff}]





[CTYP-224] Lein REPL Autocomplete in typed namespaces throws a type error Created: 02/Jun/15  Updated: 02/Jun/15

Status: Open
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: Unresolved Votes: 0
Labels: None


 Description   

This is reply's fault, should be addressed in https://github.com/trptcolin/reply/pull/163

Unsure when this will surface in a leiningen release.






[CTYP-223] checking clojure.core/keep produces Internal Error--Cannot resolve type: Option Created: 31/May/15  Updated: 31/May/15

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

Type: Defect Priority: Major
Reporter: Vince Broz Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

org.clojure/core.typed "0.2.92"



 Description   

How to reproduce:

(t/cf (t/fn [] (keep even? [1 2 3])))

Observed result:

DEPRECATED SYNTAX (NO_SOURCE_PATH): All syntax is deprecated, use clojure.core.typed/All
Type Error (NO_SOURCE_PATH:1:16) Internal Error (NO_SOURCE_PATH:1:16) Cannot resolve type: Option
Hint: Is Option in scope?
Hint: Has Option's annotation been found via check-ns, cf or typed-deps?

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

Expected result:

(t/ASeq Integer) or something like that, I would guess.

Details:

broz@macmicro:~/src/foo$ lein try org.clojure/core.typed "0.2.92"
nREPL server started on port 63244 on host 127.0.0.1 - nrepl://127.0.0.1:63244
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_40-b26
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e

user=> (require ['clojure.core.typed :as 't])
nil
user=> (t/cf (t/fn [] (keep even? [1 2 3])))
Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 9649.842771 msecs"
core.typed initialized.
DEPRECATED SYNTAX (NO_SOURCE_PATH): All syntax is deprecated, use clojure.core.typed/All
Type Error (NO_SOURCE_PATH:1:16) Internal Error (NO_SOURCE_PATH:1:16) Cannot resolve type: Option
Hint: Is Option in scope?
Hint: Has Option's annotation been found via check-ns, cf or typed-deps?

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






[CTYP-222] if-let on an hmap with an optional entry always expected to succeed Created: 30/May/15  Updated: 30/May/15

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

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


 Description   

How to reproduce:

(t/cf (t/fn [m :- (t/HMap :optional {:a String} :complete? true)] (if-let [b (get m :a)] true)))

Observed result:

[[(t/HMap :optional {:a String} :complete? true) -> true :filters {:then tt, :else ff}] {:then tt, :else ff}]

Expected result:

Something more like: [(t/HMap :optional {:a String} :complete? true) -> (t/U nil true)]

This is what you get if you replace the if-let above with if.

Return type should be (t/Option true), as the if-let will result in a nil return if the :a key is not set on the map.

Details:

broz@macmicro:~$ grep try ~/.lein/profiles.clj
[lein-try "0.4.3"]
broz@macmicro:~$ lein try org.clojure/core.typed
nREPL server started on port 52406 on host 127.0.0.1 - nrepl://127.0.0.1:52406
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_40-b26
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e

user=> (require ['clojure.core.typed :as 't])
nil
user=> (t/cf (t/fn [m :- (t/HMap :optional {:a String} :complete? true)] (if-let [b (get m :a)] true)))
Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 14055.732654 msecs"
core.typed initialized.
[[(t/HMap :optional {:a String} :complete? true) -> true :filters {:then tt, :else ff}] {:then tt, :else ff}]
user=>
}}






[CTYP-219] RPS example does not type check Created: 22/May/15  Updated: 22/May/15

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

Type: Enhancement Priority: Major
Reporter: victor chung Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

osx
clojure 1.6



 Description   

Code is here:

https://gist.github.com/kindlychung/9f932ae4c9b752f87431



 Comments   
Comment by victor chung [ 22/May/15 2:57 AM ]

How do I edit an issue?
Sorry, this should have been marked as defect instead of enhancement.





[CTYP-218] wrap-clj-repl causes error Created: 20/May/15  Updated: 21/May/15

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

Type: Defect Priority: Major
Reporter: victor chung Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

java 1.8
osx



 Description   

Add the following line into project.clj:

:repl-options {:nrepl-middleware [clojure.core.typed.repl/wrap-clj-repl]}

and start a nrepl server, i get this error:

Error loading clojure.core.typed.repl: java.io.FileNotFoundException: Could not locate clojure/tools/analyzer/env__init.class or clojure/tools/analyzer/env.clj on classpath: , compiling:(clojure/core/typed/analyze_clj.clj:1:1)
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: clojure.core.typed.repl/wrap-clj-repl in this context, compiling/private/var/folders/5d/44ctbbln4dsflgzxph1dm8wr0000gn/T/form-init7445852488836639804.clj:1:2354)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6651)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.analyze(Compiler.java:6406)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.analyze(Compiler.java:6406)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.access$100(Compiler.java:38)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6050)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.analyze(Compiler.java:6406)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.eval(Compiler.java:6700)
at clojure.lang.Compiler.eval(Compiler.java:6693)
at clojure.lang.Compiler.load(Compiler.java:7130)
at clojure.lang.Compiler.loadFile(Compiler.java:7086)
at clojure.main$load_script.invoke(main.clj:274)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invoke(main.clj:307)
at clojure.main$null_opt.invoke(main.clj:342)
at clojure.main$main.doInvoke(main.clj:420)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.RuntimeException: Unable to resolve var: clojure.core.typed.repl/wrap-clj-repl in this context
at clojure.lang.Util.runtimeException(Util.java:221)
at clojure.lang.Compiler$TheVarExpr$Parser.parse(Compiler.java:659)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)
... 38 more

The whole project.clj file:

(defproject typed-clj-test "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[org.clojure/core.typed "0.2.92"]]
:main ^:skip-aot typed-clj-test.core
:repl-options {:nrepl-middleware [clojure.core.typed.repl/wrap-clj-repl]}
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/May/15 7:46 PM ]

Add `:exclusions [org.clojure/tools.analyzer.jvm]` to your core.async dependency. core.async depends on an ancient version.

Comment by victor chung [ 21/May/15 9:11 AM ]

Maybe we should submit an issue at their github repo?





[CTYP-216] PermGen memory leak when type checking with faulty types Created: 16/May/15  Updated: 21/Jun/15

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

Type: Defect Priority: Major
Reporter: Olli Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:
  • OSX 10.10
  • Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
  • Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
  • Clojure 1.6.0


 Description   

This is not the only instance where I ran into the java.lang.OutOfMemoryError, but the following is a rather minimal case that reproduced the problem for me consistently before I upgraded my JVM options to use higher MaxPermSize (was using the default Leiningen settings before).

https://gist.github.com/luxbock/bd54c9e519527cdf855a



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 21/Jun/15 8:51 AM ]

Since Java 8 removed the concept of perm gen space, does it help to upgrade to Java 8?





[CTYP-209] method-type is broken Created: 08/Apr/15  Updated: 08/Apr/15

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

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

[org.clojure/core.typed "0.2.84"]
[org.clojure/clojure "1.6.0"]



 Description   
reiska.core=> (t/method-type 'java.lang.Runtime/availableProcessors)

AssertionError Assert failed: Cannot find var: clojure.core.typed.check/Method->Type
(var? var)  clojure.core.typed.current-impl/v (current_impl.clj:19)





[CTYP-204] Assoc doesn't work with multiple entries Created: 10/Mar/15  Updated: 10/Mar/15

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

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


 Description   

(from https://groups.google.com/d/msg/clojure-core-typed/4z_7WnqZsyI/53jlUHQfWhEJ)

The following code:

(t/ann new-ar (t/All [[m :< (t/Map t/Any t/Any)]] [m -> (t/Assoc m ':id Number ':version Number)]))
(defn new-ar
[detail]
{:post [(not (nil? (:id %)))
(zero? (:version %))]}
(assoc detail :id 10 :version 0))

gives the following error:

Type Error (qfi/health/core/domain/model/common.clj:40:3) Cannot assoc args `[(clojure.core.typed/Val :id) {:then tt, :else ff}] [(clojure.core.typed/Val 10) {:then tt, :else ff}] [(clojure.core.typed/Val :version) {:then tt, :else ff}] [(clojure.core.typed/Val 0) {:then tt, :else ff}]` on m
in: (assoc detail :id 10 :version 0)






[CTYP-202] Provide a way to annotate a throw-on-nil function Created: 27/Feb/15  Updated: 27/Feb/15

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

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


 Description   

This functions seems impossible to annotate at the moment because the input and output should be the same only if the input is not nil.
We need a way to describe the output type as: The input type without nil
This is useful if the input type is for example (U String nil) and we want to hand the validation off to our throw-on-nil function.

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

(t/ann throw-on-nil (t/All [x] (t/IFn [x -> x])))
(defn throw-on-nil
  ([value] (if (nil? value)
             (throw (Exception. "Value is nil"))
             value)))

(t/ann -main [(t/U nil String) * -> t/Any])
(defn -main [& args]
  (t/let [input (first args)
          in :- String (throw-on-nil input)]
    (println in)))

Error:

Type Error (example/core.clj:13:26) Polymorphic function throw-on-nil could not be applied to arguments:
Polymorphic Variables:
        x

Domains:
        x

Arguments:
        (t/U nil String)

Ranges:
        x

with expected type:
        java.lang.String

in: (throw-on-nil input)
in: (throw-on-nil input)


Type Checker: Found 1 error





[CTYP-201] Calling a multimethod from a protocol function breaks the type checker Created: 27/Feb/15  Updated: 27/Feb/15

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

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


 Description   

When i call a multimethod from within a protocol implementation, i receive a long error.

Minimum working example including error output:
https://github.com/exi/core-typed-errors

Code:

(ns example.core
  (:import java.io.File)
  (:require [clojure.core.typed :as t]))

(declare dispatcher)

(t/ann-protocol MProto
                myfn (t/IFn [MProto File -> String]))
(defprotocol MProto
  (myfn [this obj]))

(t/ann-record MRec [name :- String])
(defrecord MRec [name]
  MProto
  (myfn [this obj] (dispatcher this obj)))

(t/ann dispatcher (t/IFn [MRec File -> String]))
(defmulti dispatcher (fn [rec obj] (class obj)))

(defmethod dispatcher
  File
  [rec obj]
  (:name rec))

(defn -main [& args]
  (let [rec (MRec. "myname")
        file (File. ".")]
    (when (not (nil? file))
      (println (myfn rec file)))))

Error message:

Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 3564.305528 msecs"
core.typed initialized.
Start collecting example.core
Finished collecting example.core
Collected 1 namespaces in 681.706266 msecs
Not checking clojure.core.typed (does not depend on clojure.core.typed)
Start checking example.core
nil Not checking example.core/MProto definition
13:  Not checking example.core/->MRec definition
Checked example.core in 1019.900549 msecs
WARNING: Type Checker: Definition missing: clojure.core/assert-same-protocol 
Hint: Use :no-check metadata with ann if this is an unchecked var
WARNING: Type Checker: Definition missing: clojure.core/-cache-protocol-fn 
Hint: Use :no-check metadata with ann if this is an unchecked var
WARNING: Type Checker: Definition missing: clojure.core/-reset-methods 
Hint: Use :no-check metadata with ann if this is an unchecked var
Checked 2 namespaces  in 1717.619162 msecs
Type Error (example/core.clj:9:1) Polymorphic function clojure.core/alter-meta! could not be applied to arguments:
Polymorphic Variables:
	b

Domains:
	clojure.lang.IReference [(t/U nil (IPersistentMap t/Any t/Any)) b ... b -> (t/U nil (IPersistentMap t/Any t/Any))] b ... b

Arguments:
	(Var t/Any t/Any) (t/All [b c d] (t/IFn [(t/Map b c) b c -> (t/Map b c)] [(t/Vec d) t/AnyInteger d -> (t/Vec d)])) (t/Val :doc) nil

Ranges:
	(t/U nil (IPersistentMap t/Any t/Any))

in: (clojure.core/alter-meta! (var example.core/MProto) clojure.core/assoc :doc nil)
in: (clojure.core/alter-meta! (var example.core/MProto) clojure.core/assoc :doc nil)


Type Error (example/core.clj:9:1) Untyped var reference: clojure.core/assert-same-protocol
Hint: Add the annotation for clojure.core/assert-same-protocol via check-ns or cf
in: (var clojure.core/assert-same-protocol)


Type Error (example/core.clj) Cannot call instance method example.core.MProto/myfn on type clojure.core.typed/Any
in: (.myfn gf__this__763 gf__obj__764)


Type Error (example/core.clj) Instance method example.core.MProto/myfn could not be applied to arguments:


Domains:
	Object

Arguments:
	t/Any

Ranges:
	(t/U nil Object)

in: (.myfn gf__this__763 gf__obj__764)
in: (.myfn gf__this__763 gf__obj__764)


Type Error (example/core.clj) Instance field __methodImplCache expected clojure.lang.AFunction, actual [clojure.core.typed/Any clojure.core.typed/Any -> clojure.core.typed/Any]
in: (.-__methodImplCache G__753)


Type Error (example/core.clj) Static method clojure.lang.Util/classOf could not be applied to arguments:


Domains:
	Object

Arguments:
	t/Any

Ranges:
	(t/U nil Class)

in: (clojure.lang.Util/classOf gf__this__766)
in: (clojure.lang.Util/classOf gf__this__766)


Type Error (example/core.clj) Cannot call instance method clojure.lang.MethodImplCache/fnFor on type (clojure.core.typed/U nil clojure.lang.MethodImplCache)
in: (.fnFor cache__5915__auto__ (clojure.lang.Util/classOf gf__this__766))


Type Error (example/core.clj) Cannot invoke type: IFn
in: (f__5916__auto__ gf__this__766 gf__obj__767)


Type Error (example/core.clj) Unannotated var clojure.core/-cache-protocol-fn
Hint: Add the annotation for clojure.core/-cache-protocol-fn via check-ns or cf
in: clojure.core/-cache-protocol-fn


Type Error (example/core.clj) Instance field __methodImplCache expected clojure.lang.AFunction, actual [clojure.core.typed/Any clojure.core.typed/Any -> Error]
in: (.-__methodImplCache f__5918__auto__)


Type Error (example/core.clj) Type mismatch:

Expected: 	(t/U nil MethodImplCache)

Actual: 	t/Any
in: cache__5917__auto__


Type Error (example/core.clj:9:1) Polymorphic function clojure.core/alter-var-root could not be applied to arguments:
Polymorphic Variables:
	w
	r
	b

Domains:
	(t/Var2 w r) [r b ... b -> w] b ... b

Arguments:
	(Var t/Any t/Any) (t/All [k v] (t/IFn [nil * -> nil] [(clojure.lang.IPersistentMap k v) (clojure.lang.IPersistentMap k v) * -> (clojure.lang.IPersistentMap k v)] [(t/Option (clojure.lang.IPersistentMap k v)) * -> (t/Option (clojure.lang.IPersistentMap k v))])) (t/HMap :mandatory {:method-builders (APersistentMap (t/Var2 t/Nothing t/Any) [t/Any -> [t/Any t/Any -> Error] :filters {:then tt, :else ff}]), :method-map (t/HMap :mandatory {:myfn (t/Val :myfn)} :complete? true), :var (Var t/Any t/Any), :sigs (t/HMap :mandatory {:myfn (t/HMap :mandatory {:file (t/Val "example/core.clj"), :line (t/Val 10), :column (t/Val 4), :end-line (t/Val 10), :end-column (t/Val 9), :name (t/Val myfn), :arglists (ISeq (t/HVec [(t/Val this) (t/Val obj)])), :doc nil} :complete? true)} :complete? true), :on (t/Val example.core.MProto), :on-interface (t/Val example.core.MProto)} :complete? true)

Ranges:
	w

in: (clojure.core/alter-var-root (var example.core/MProto) clojure.core/merge (clojure.core/assoc {:on (quote example.core.MProto), :on-interface example.core.MProto} :sigs (quote {:myfn {:doc nil, :arglists ([this obj]), :name myfn, :end-column 9, :end-line 10, :column 4, :line 10, :file "example/core.clj"}}) :var (var example.core/MProto) :method-map {:myfn :myfn} :method-builders {(clojure.core/intern clojure.core/*ns* (clojure.core/with-meta (quote myfn) (clojure.core/merge (quote {:doc nil, :arglists ([this obj]), :name myfn, :end-column 9, :end-line 10, :column 4, :line 10, :file "example/core.clj"}) {:protocol (var example.core/MProto)}))) (fn* ([cache__5917__auto__] (let* [G__754 (fn* ([gf__this__763 gf__obj__764] (.myfn gf__this__763 gf__obj__764))) f__5918__auto__ (fn* G__753 ([gf__this__766 gf__obj__767] (let* [cache__5915__auto__ (.-__methodImplCache G__753) f__5916__auto__ (.fnFor cache__5915__auto__ (clojure.lang.Util/classOf gf__this__766))] (if f__5916__auto__ (f__5916__auto__ gf__this__766 gf__obj__767) ((clojure.core/-cache-protocol-fn G__753 gf__this__766 example.core.MProto G__754) gf__this__766 gf__obj__767)))))] (do (set! (.-__methodImplCache f__5918__auto__) cache__5917__auto__) f__5918__auto__))))}))
in: (clojure.core/alter-var-root (var example.core/MProto) clojure.core/merge (clojure.core/assoc {:on (quote example.core.MProto), :on-interface example.core.MProto} :sigs (quote {:myfn #}) :var (var example.core/MProto) ...))


Type Error (example/core.clj) Unannotated var clojure.core/-reset-methods
Hint: Add the annotation for clojure.core/-reset-methods via check-ns or cf
in: clojure.core/-reset-methods


Type Checker: Found 13 errors
Found errors
Subprocess failed





[CTYP-197] No matching arities when defining multiple arity protocol method Created: 25/Jan/15  Updated: 08/May/15

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

Type: Defect Priority: Major
Reporter: Joshua Griffith Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 1
Labels: bug, defprotocol, deftype
Environment:

Clojure 1.6.0 and 1.7.0-alpha5


Attachments: File arity.clj     Text File typecheck.log    

 Description   

When defining multiple-arity protocol methods with clojure.core.typed/defprotocol, deftypes implementing these methods fail to typecheck with "No matching arities" errors. See attached test case.



 Comments   
Comment by Johan Gall [ 08/May/15 1:18 AM ]

i found a quite similar problem with defrecord. Is there some kind of workaround?

project.clj http://pastebin.com/bn6giuvH
core_typed_bug/core.clj http://pastebin.com/JjfhWLSH
error message http://pastebin.com/djsAicd1

with clojure 1.7.0-beta2 and core.typed 0.2.87

(ns core-typed-bug.core
(:require [ clojure.core.typed :as t ]))

(t/defprotocol P
(f
[a] :- Any
[a b :- Any] :- Any))

(t/ann-record R [])
(defrecord R []
P
(f [a] 1)
(f [a b] 2))

will give the following arity related errors:

Collected 1 namespaces in 758.831468 msecs
Not checking clojure.core.typed (does not depend on clojure.core.typed)
Start checking core-typed-bug.core
10: Not checking core-typed-bug.core/->R definition
Checked core-typed-bug.core in 923.152062 msecs
Checked 2 namespaces in 1702.704416 msecs
Type Error (core_typed_bug/core.clj:10:1) No matching arities: [R t/Any -> t/Any]
in: (f [a] 1)

Type Error (core_typed_bug/core.clj:10:1) No matching arities: [R -> t/Any] in: (f [a b] 2)

Type Checker: Found 2 errors
Found errors





[CTYP-195] Support for clojure.core/extend is broken when used with typed.core/defprotocol Created: 15/Jan/15  Updated: 15/Jan/15

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

Type: Defect Priority: Major
Reporter: Daniel Ziltener Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

core.typed 0.2.77



 Description   

Using extend with a protocol defined using typed.core/defprotocol, the following error occurs:

Type Error (client/clojurefx.clj:31:1) Internal Error (client/clojurefx.clj:31:1) Expecting Protocol type, found clojure.core.typed.type_rep.TypeFn@38c0769f






[CTYP-194] HMap merged type Created: 14/Jan/15  Updated: 14/Jan/15

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

Type: Enhancement Priority: Major
Reporter: Bryan Hoyle Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: enhancement, hmap, merge
Environment:

All



 Description   

It would be nice to be able to merge several HMaps in order to simulate a parent-child relationship.
For example

(defalias Parent (t/HMap :mandatory {:type t/Keyword}))
(defalias Child1 (t/HMap :mandatory {:type (t/Value :child1)
                                     :value t/Int})

(defalias Child2 (t/HMap :mandatory {:type (t/Value :child2)
                                     :size t/Int})

(ann is-child1?
    Parent -> t/Bool])
(defn is-child1? [child]
    (= (:type child) :child1))

And have that typecheck appropriately.
As of right now, one would have to do something like

(defalias Parent (t/U Child1 Child2))

which means you have to keep track of the definition in two places to make it work as expected.






[CTYP-192] Use memoization in file-mapping to improve performance. Created: 10/Jan/15  Updated: 22/Jul/15

Status: Open
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: None
Fix Version/s: 0.3.x

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

Attachments: Text File memoize.patch    
Patch: Code

 Description   

Use of the `:file-mapping` to `check-ns-info` now increases run time by a good factor of 5. By memoizing the conversion of types into strings, we can reduce this to a factor of 2. This will also reduce memory consumption, as multiple entries for the same symbol will now contain references to the same string, rather than copies.






[CTYP-191] Bad type syntax when parsing types of macro-generated anonymous functions from required namespaces (when the types are composed, for instance (Option AnyInteger)) Created: 09/Jan/15  Updated: 20/Jul/15

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

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


 Description   
(defmacro lol2 []
      (let [a (list `typed/Option `typed/AnyInteger)]
        `(fn [] :- ~a 1)))
    
    
    (defmacro lol []
      `(fn [] :- (typed/Option typed/AnyInteger) 1))

    (clojure.core.typed/def lol*2 :- [-> (typed/Option typed/AnyInteger)]
      (lol2))
    
    (clojure.core.typed/def lol* :- (typed/Option typed/AnyInteger)
      (lol))

I put this code in namespace A, both typecheck without problem.

When A is depended on by namespace B, when B is checked
lol*2 is completely fine but lol* crashes with

"Bad type syntax: (clojure.core.typed/Option clojure.core.typed/AnyInteger)"

The following works fine.

(defmacro lol**3 []
      `(fn [] :- typed/AnyInteger 1))
    
    (clojure.core.typed/def lol*3 :- typed/AnyInteger
      (lol**3))





[CTYP-188] ann-record fails for argument-less records Created: 05/Jan/15  Updated: 27/Feb/15

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

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

Clojure 1.7.0-alpha4, core.typed 0.2.76



 Description   

ann-record fails for records without arguments. The whole error is as follows:

1. Unhandled java.lang.AssertionError
   Assert failed: (every? r/Type? types)

                type_ctors.clj:  497  clojure.core.typed.type-ctors/In
                   RestFn.java:  137  clojure.lang.RestFn/applyTo
                      core.clj:  626  clojure.core/apply
               assoc_utils.clj:   34  clojure.core.typed.assoc-utils/fn
               assoc_utils.clj:   23  clojure.core.typed.assoc-utils/fn/G
                type_ctors.clj: 2181  clojure.core.typed.type-ctors/reduce-type-transform/fn/iter/fn
                  LazySeq.java:   40  clojure.lang.LazySeq/sval
                  LazySeq.java:   49  clojure.lang.LazySeq/seq
                       RT.java:  485  clojure.lang.RT/seq
                      core.clj:  135  clojure.core/seq
                      core.clj: 2539  clojure.core/every?
                type_ctors.clj: 2179  clojure.core.typed.type-ctors/reduce-type-transform/fn
                 protocols.clj:  148  clojure.core.protocols/fn
                 protocols.clj:   19  clojure.core.protocols/fn/G
                 protocols.clj:   31  clojure.core.protocols/seq-reduce
                 protocols.clj:   53  clojure.core.protocols/fn
                 protocols.clj:   13  clojure.core.protocols/fn/G
                      core.clj: 6461  clojure.core/reduce
                type_ctors.clj: 2184  clojure.core.typed.type-ctors/reduce-type-transform
                   RestFn.java:  494  clojure.lang.RestFn/invoke
               assoc_utils.clj:  127  clojure.core.typed.assoc-utils/assoc-type-pairs
                   RestFn.java:  139  clojure.lang.RestFn/applyTo
                      core.clj:  628  clojure.core/apply
               assoc_utils.clj:  367  clojure.core.typed.assoc-utils/merge-pair/iter/fn/fn
               assoc_utils.clj:  342  clojure.core.typed.assoc-utils/merge-pair/iter/fn
                  LazySeq.java:   40  clojure.lang.LazySeq/sval
                  LazySeq.java:   49  clojure.lang.LazySeq/seq
                       RT.java:  485  clojure.lang.RT/seq
                      core.clj:  135  clojure.core/seq
                      core.clj: 2559  clojure.core/some
                type_ctors.clj: 2161  clojure.core.typed.type-ctors/union-or-nil
               assoc_utils.clj:  342  clojure.core.typed.assoc-utils/merge-pair
                type_ctors.clj: 2181  clojure.core.typed.type-ctors/reduce-type-transform/fn/iter/fn
                  LazySeq.java:   40  clojure.lang.LazySeq/sval
                  LazySeq.java:   49  clojure.lang.LazySeq/seq
                       RT.java:  485  clojure.lang.RT/seq
                      core.clj:  135  clojure.core/seq
                      core.clj: 2559  clojure.core/some
                type_ctors.clj: 2161  clojure.core.typed.type-ctors/union-or-nil
                type_ctors.clj: 2184  clojure.core.typed.type-ctors/reduce-type-transform
                   RestFn.java:  445  clojure.lang.RestFn/invoke
               assoc_utils.clj:  375  clojure.core.typed.assoc-utils/merge-types
                   RestFn.java:  139  clojure.lang.RestFn/applyTo
                      core.clj:  628  clojure.core/apply
                     check.clj: 1072  clojure.core.typed.check/merge)17420
                   RestFn.java:  423  clojure.lang.RestFn/invoke
                  MultiFn.java:  233  clojure.lang.MultiFn/invoke
                     check.clj: 1245  clojure.core.typed.check/check :invoke17476/fn
                     check.clj: 1243  clojure.core.typed.check/check :invoke17476


 Comments   
Comment by Daniel Ziltener [ 05/Jan/15 10:59 PM ]

Ok, mistake, this actually happens in certain assoc situations.

Comment by Reno Reckling [ 27/Feb/15 8:25 PM ]

Could you please post a minimum working example or some code to trigger this bug?





[CTYP-177] Compile error with core.async Created: 02/Dec/14  Updated: 22/Jul/15

Status: Open
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: None
Fix Version/s: Backlog

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

[org.clojure/clojure "1.6.0"]
[org.clojure/core.typed "0.2.72"]
[org.clojure/core.async "0.1.267.0-0d7780-alpha"]



 Description   

The following namespace gives me a compile-time error:

(ns typed-async-whatsit.core
  (:require [clojure.core.async :as a]
            [clojure.core.typed :as t]
            [clojure.core.typed.async :as t.a]))

(t/ann connect [-> nil])
(defn connect
  []
  (let [ch (t.a/chan :- String)]
    (t.a/go-loop []
      (a/>! ch "hey hey"))
    nil))

The error is:

Exception in thread "main" java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.util.Map$Entry, compiling:(typed_async_whatsit/core.clj:22:5)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6651)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyze(Compiler.java:6406)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyze(Compiler.java:6406)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.access$100(Compiler.java:38)
    at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:538)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyze(Compiler.java:6406)
    at clojure.lang.Compiler.eval(Compiler.java:6707)
    at clojure.lang.Compiler.load(Compiler.java:7130)
    at clojure.lang.RT.loadResourceScript(RT.java:370)
    at clojure.lang.RT.loadResourceScript(RT.java:361)
    at clojure.lang.RT.load(RT.java:440)
    at clojure.lang.RT.load(RT.java:411)
    at clojure.core$load$fn__5066.invoke(core.clj:5641)
    at clojure.core$load.doInvoke(core.clj:5640)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5446)
    at clojure.core$load_lib$fn__5015.invoke(core.clj:5486)
    at clojure.core$load_lib.doInvoke(core.clj:5485)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:626)
    at clojure.core$load_libs.doInvoke(core.clj:5524)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:626)
    at clojure.core$require.doInvoke(core.clj:5607)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at user$eval1884.invoke(form-init6964782882533247650.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6703)
    at clojure.lang.Compiler.eval(Compiler.java:6666)
    at clojure.core$eval.invoke(core.clj:2927)
    at clojure.main$eval_opt.invoke(main.clj:288)
    at clojure.main$initialize.invoke(main.clj:307)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.doInvoke(main.clj:420)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
    at user$eval1870.invoke(form-init6964782882533247650.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6703)
    at clojure.lang.Compiler.eval(Compiler.java:6693)
    at clojure.lang.Compiler.load(Compiler.java:7130)
    at clojure.lang.Compiler.loadFile(Compiler.java:7086)
    at clojure.main$load_script.invoke(main.clj:274)
    at clojure.main$init_opt.invoke(main.clj:279)
    at clojure.main$initialize.invoke(main.clj:307)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.doInvoke(main.clj:420)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
Caused by: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.util.Map$Entry
    at clojure.lang.APersistentMap$KeySeq.first(APersistentMap.java:154)
    at clojure.lang.RT.first(RT.java:577)
    at clojure.core$first.invoke(core.clj:55)
    at clojure.core$zipmap.invoke(core.clj:2790)
    at clojure.core.async.impl.ioc_macros$parse_to_state_machine$fn__3229.invoke(ioc_macros.clj:806)
    at clojure.core.async.impl.ioc_macros$get_plan.invoke(ioc_macros.clj:77)
    at clojure.core.async.impl.ioc_macros$parse_to_state_machine.invoke(ioc_macros.clj:805)
    at clojure.core.async.impl.ioc_macros$state_machine.invoke(ioc_macros.clj:990)
    at clojure.core.typed.async$go.doInvoke(async.clj:328)
    at clojure.lang.RestFn.invoke(RestFn.java:442)
    at clojure.lang.Var.invoke(Var.java:388)
    at clojure.lang.AFn.applyToHelper(AFn.java:160)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.lang.Compiler.macroexpand1(Compiler.java:6552)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6630)
    ... 82 more


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 22/Jul/15 1:31 AM ]

This might have been a conflict in the tools.analyzer version. We should check core.typed 0.3.8
which inlines its own t.a.j version.





[CTYP-176] No such var: ana/ns->relpath when loading the ClojureScript typechecker Created: 08/Oct/14  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: ClojureScript Checker
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect Priority: Major
Reporter: Daniel Woelfel Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 2
Labels: None


 Description   

Looks like ns->relpath moved from cljs.analyzer to cljs.util: https://github.com/clojure/clojurescript/commit/88873ed1053810d869febe28e58a45fa24769437#diff-d7b925f0cdb496ec057f02327d4e1b0dR6



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 08/Oct/14 11:43 PM ]

Thanks, I'll keep this in mind when I upgrade the ClojureScript dep.

Comment by Vic Goldfeld [ 08/Apr/15 1:00 PM ]

I'm getting this error now with all the latest ClojureScript and core.typed.





[CTYP-173] (first (filter ...)) type checks in Clojure, not ClojureScript Created: 30/Aug/14  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: ClojureScript Checker
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect Priority: Major
Reporter: Kris Jenkins Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

[[org.clojure/clojure "1.6.0"]
[org.clojure/core.typed "0.2.67"]
[org.clojure/clojurescript "0.0-2322"]]



 Description   

This code type check in Clojure:

(ann ffilter
  (All [a]
       [[a -> Any] (Option (Seqable a)) -> (Option a)]))

(defn ffilter
  [pred coll]
  (first (filter pred coll)))

But fails under ClojureScript with:

Type Error (typed-playground.clojurescript:26:3) Polymorphic function cljs.core/first could not be applied to arguments:
Polymorphic Variables:
x

Domains:
(clojure.core.typed/HSequential [x clojure.core.typed/Any *])
(cljs.core.typed/Option (cljs.core.typed/EmptySeqable x))
(cljs.core.typed/NonEmptySeqable x)
(cljs.core.typed/Option (cljs.core.typed/Seqable x))

Arguments:
(cljs.core/ASeq a)

Ranges:
x :object {:path [(Nth 0)], :id 0}
nil
x
(cljs.core.typed/Option x)

with expected type:
(cljs.core.typed/Option a)

in: (cljs.core/first (cljs.core/filter pred coll))
in: (cljs.core/first (cljs.core/filter pred coll))






[CTYP-171] nil should not be treated as subtype of repeat list/vector Created: 22/Aug/14  Updated: 22/Aug/14

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

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

Attachments: File nil-is-not-subtype-of-repeat-list.diff    

 Description   

this patch is based on commit 35158d4340b1afda3b4073ae6efd7d6b1b08ea7e which is https://github.com/clojure/core.typed/commit/35158d4340b1afda3b4073ae6efd7d6b1b08ea7e see discuss [here](https://github.com/clojure/core.typed/pull/8#discussion-diff-16573748)






[CTYP-165] GSOC 2014 Heterogeneous operations & Dotted Polymorphism Created: 02/Aug/14  Updated: 03/Aug/14

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

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

Attachments: File patch.diff    

 Description   

interface changed:

syntax:

  • add `:repeat true` to HSeq, HVec and HSequential
  • add `<*` and `<...` to Function

type:

  • Function (add prest, pdot)
  • Hsequential (add repeat attribute)
  • HSeq (add repeat attribute)
  • HVec (add repeat attribute)
  • AssocType (add dentries support)

internal function:

  • make-Function (use keyword argument instead of position argument)
  • check-fn-method1-rest-type in check.clj (add prest, pdot keyword argument)
  • merge function of parse/unparse, frees, fold, substitute-dots, substitute-dotted for HSeq, HVec and HSequential to use one function.

check result:

  • apply hash-map will now returns Map instead of HMap

docs:

  • add tutorial on inference to docs directory

built-in function annotation changed/added:

  • hash-map
  • apply
  • assoc
  • keep-indexed


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 03/Aug/14 8:24 AM ]

I tried applying and got this error.

ambrose@ambrose-VirtualBox:~/Projects/core.typed-branches/di$ git am --keep-cr -s --ignore-whitespace < patch.diff
Applying: add :repeat field to HeterogeneousVector HeterogeneousSeq and HSequential
error: src/main/clojure/clojure/core/typed/type_rep.clj: does not exist in index
Patch failed at 0001 add :repeat field to HeterogeneousVector HeterogeneousSeq and HSequential
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".

Most of the src/main files are now in module-check/src/main.

Comment by Ambrose Bonnaire-Sergeant [ 03/Aug/14 8:26 AM ]

Just looked at your branch, not really sure where this is going wrong.

Comment by Di Xu [ 03/Aug/14 8:33 AM ]

well, I'm using

git format-patch master --stdout > patch.diff

to format patch, what should I use?

Comment by Ambrose Bonnaire-Sergeant [ 03/Aug/14 8:38 AM ]

Yea that's what I would use... I don't know enough git.

Comment by Di Xu [ 03/Aug/14 9:32 AM ]

it seems [patch is not able to do this kind of work](https://stackoverflow.com/questions/2285699/git-how-to-create-patches-for-a-merge) because I merge master once in the middle of my commit sequence.

I also failed to rebase it, because you change source dir, rebase failed on my first commit.

I'm not sure how to solve it now..

Comment by Ambrose Bonnaire-Sergeant [ 03/Aug/14 9:50 AM ]

I'll just pull from your Github branch at this point.

You've included all the changes in your patch.

Comment by Di Xu [ 03/Aug/14 9:59 AM ]

ok, then.





[CTYP-143] extend & extend-protocol with (Class/forName "[B") as Class dispatch value fails Created: 12/May/14  Updated: 22/Jul/15

Status: Open
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: None
Fix Version/s: Backlog

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


 Description   

it can be observed in this example: https://gist.github.com/mpenet/23fd53aabc853eb7e565

using extend instead of extend-protocol returns a type error:

Type Error (qbits/alia/codec.clj:75:1) Must provide
a Class or nil as first argument to extend, got
java.lang.Class

This issue in clj.core could also be of interest http://dev.clojure.org/jira/browse/CLJ-1381






[CTYP-140] HSequential things should correctly erase dotted arguments Created: 09/May/14  Updated: 22/Jul/15

Status: Open
Project: core.typed
Component/s: Core type system
Affects Version/s: None
Fix Version/s: Backlog

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


 Description   

These unit tests should pass.






[CTYP-129] select-keys on HMap returns Map with union key and value types Created: 30/Mar/14  Updated: 30/Mar/14

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

Type: Defect Priority: Major
Reporter: Timo Mihaljov Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 1
Labels: None
Environment:

core.typed 0.2.40



 Description   

Currently select-keys on an HMap returns a Map with unions for keys and values.

=> (t/cf {:foo 1, :bar "2", :baz \3})
[(HMap :mandatory {:baz (Value \3), :bar (Value "2"), :foo (Value 1)} :complete? true) {:then tt, :else ff}]

=> (t/cf (select-keys {:foo 1, :bar "2", :baz \3}
                      [:foo :bar]))
(t/Map (U (Value :baz) (Value :foo) (Value :bar)) (U (Value 1) (Value \3) (Value "2")))

This results in type errors when select-keys is used to remove extra keys from an HMap.

Expected behaviour: select-keys should return an HMap with a subset of the :mandatory keys of its input HMap.






[CTYP-102] large hashmaps: failure to discover subtype and error-output to complex to understand Created: 02/Feb/14  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: Core type system
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect Priority: Major
Reporter: Cees van Kemenade Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: error-reporting, hash-map
Environment:

core.typed 0.2.25


Attachments: File longOutput.clj     File show-error.output    

 Description   

I am applying core.typed to a project that processes sequences of fairly large hash-maps. I run into two issues:
1. The error output is to large to be interpreted by a human (4k per error)
2. The reported error seems to be incorrect as the expected-type and actual type seem to match.

I came to this conclusion by writing a function that compared the expected type and the actuals type. This function is included too and might be an example of how to produce more compact and readible output for errors on large hash-maps.

The longOutput.clj contains the function that fails (derive-sms_msg-fmt-fail ..) and the nearly similar function (derive-sms_msg-fmt ..) that passes (check-ns).

The file also contains function (show-error) which prints a copy of the type-error and subsequently analyses the derived type with the expected type. The derived type is a union of the expected type and some derivatives based on the inclusion of optional keys. So I as far as I can see the union is subtype of the expected type and the reported error is incorrect.

An example of the error-analysis is included in the file show-error.output.



 Comments   
Comment by Cees van Kemenade [ 03/Feb/14 2:40 AM ]

PS: I could imagine that the current (show-error ..) could service as a basis for more compact error-messages on large hashmaps (using length of output as a criterium to decide whether the current error-format or the diffence-analysis results in the most compact error-report).

PS: I strongly believe in the big advantages of a static type-checker. But with the current error-messages it is nearly impossible to migrate a project involving large hash-maps due to the volumunuous error-output.

Comment by Ambrose Bonnaire-Sergeant [ 03/Feb/14 11:00 PM ]

Hi Cees,

Thanks for the detailed report, it really helps. I'll look into this.





[CTYP-88] with-meta doesn't type check with vectors or hash-maps. Created: 16/Oct/13  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: Core type system
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect Priority: Major
Reporter: Russell Mull Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

clojure 1.5.1
core.typed 0.2.13



 Description   
(cf (with-meta 'a {})) 
;; => (Value a)  ; expected result

(cf (with-meta [] {}))
;; => AssertionError Assert failed: 1: Inferred type [] is not between bounds Nothing and clojure.lang.IObj
(and (subtype? inferred upper-bound) (subtype? lower-bound inferred))  clojure.core.typed.cs-gen/subst-gen/fn--10379 (cs_gen.clj:1333)

This also fails with an empty hash-map literal. Lists and sets work.






[CTYP-72] merge doesn't seem to like records Created: 28/Sep/13  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: Core type system
Affects Version/s: 0.2, 0.3.0
Fix Version/s: Backlog

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


 Description   

I'm pretty sure this should pass

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

(ann-record X [a :- Number])
(defrecord X [a])

(ann x X)
(def x (merge (X. 3) {:z 4}))

but it gives

Type Error (moonrise:8:8) Polymorphic function clojure.core/merge could not be applied to arguments:
Polymorphic Variables:
	k
	v

Domains:
	nil *
	(clojure.lang.IPersistentMap k v) (clojure.lang.IPersistentMap k v) *
	(Option (clojure.lang.IPersistentMap k v)) *

Arguments:
	moonrise.X (HMap :mandatory {:z (Value 4)} :complete? true)

Ranges:
	nil
	(clojure.lang.IPersistentMap k v)
	(Option (clojure.lang.IPersistentMap k v))

with expected type:
	moonrise.X

in: (clojure.core/merge (new moonrise.X 3) (quote {:z 4}))
in: (def x (clojure.core/merge (new moonrise.X 3) (quote {:z 4})))


Type Checker: Found 1 error





[CTYP-52] Heterogeneous Vector is not ISeqable in CLJS Created: 10/Sep/13  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: ClojureScript Checker
Affects Version/s: None
Fix Version/s: Backlog

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

ClojureScript 0.0-1859, Mac OS X 10.8.4



 Description   

Following code snipped exemplifies the error:

(ann update-first [(Vector* number number) number -> (Vector* number number)]) 
(defn update-first [my-vec new-first] (assoc my-vec 1 new-first))

Produces the following error when type-checking:

Type Error [file] Polymorphic function clojure.core/nth could not be applied to arguments:
Polymorphic Variables:
	x
	y

Domains:
	(U (cljs.core/ISeqable x) nil) int
	(U (cljs.core/ISeqable x) nil) int y

Arguments:
	chaser-cljs.coords/CoordsT (Value 1) nil

Ranges:
	x
	(U y x)

in: (clojure.core/nth vec__8823 1 nil)
in: (clojure.core/nth vec__8823 1 nil)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/15 11:30 AM ]

This is probably fixed, but we need a test.





[CTYP-49] Applying flow filter resulted in local being bottom Created: 07/Sep/13  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: Core type system
Affects Version/s: None
Fix Version/s: Backlog

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


 Description   

Close to minimal case: https://gist.github.com/pnf/e208b0d44860aedc9c9d



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 08/Sep/13 1:39 AM ]

Can't reproduce this particular report, however the flow filter error probably needs to be fixed.

https://gist.github.com/anonymous/6482420

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

Added test to verify this. https://github.com/clojure/core.typed/commit/f96d74a76fe72d26c06b1648df424f5314aa7cad

The general problem of the flow filter error still needs addressing.





[CTYP-47] Expected: IFn, Actual (Fn [Any -> Any]) Created: 05/Sep/13  Updated: 09/Sep/13

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

Type: Defect Priority: Major
Reporter: André Thieme Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: jfx


 Description   
Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(def-alias Promise (clojure.lang.IDeref Any))
(ann ^:no-check clojure.core/promise [-> Promise])
(ann ^:no-check clojure.core/deliver (All [t] [Promise t -> t]))

(ann primary-stage Stage)
(defonce ^Stage primary-stage
  (when-not *compile-files*
    (let [s (promise)]
      (SplendidJFX/launchApplication (fn> [x :- Any] (deliver s x)))
      @s)))

When doing (check-ns) it results in an unexpected error:
Type Error (splendid.jfx:27:7) Type mismatch:
Expected: IFn
Actual: (Fn [Any -> Any])
in: (splendid.SplendidJFX/launchApplication (clojure.core.typed/fn>-ann (fn* (# #)) (quote (#))))



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 07/Sep/13 8:51 AM ]

Confirmed. This needs a little work and refactoring to fix.

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

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

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

Design work happening here: http://dev.clojure.org/display/design/Cleaning+up+Type+Syntax





[CTYP-35] Should use fresh names when checking plambdas Created: 26/Aug/13  Updated: 26/Aug/13

Status: Open
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: Unresolved Votes: 0
Labels: None


 Description   

See the Typed Racket implementation. Poly-fresh* is only needed when checking a plambda.

ambrosebs: why is Poly-fresh: needed in the plambda type checking code, but nowhere else?
asumu: ambrosebs: that's the only place where the body of the lambda is checked.
asumu: The only purpose of Poly-fresh is to make sure the references to the bound type variable in the body are resolved in the correct way.
asumu: When the type is just manipulated otherwise, it doesn't matter.






[CTYP-32] Cannot instantiate variables that have bounds Created: 29/Jul/13  Updated: 20/Jul/15

Status: Open
Project: core.typed
Component/s: Core type system
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect Priority: Major
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: newbie


 Description   

Trying to implement this example: http://www.scala-lang.org/node/136

The result: core.typed doesn't know that other bounded type variables can be substituted.

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






Generated at Mon Aug 31 18:56:00 CDT 2015 using JIRA 4.4#649-r158309.