<< 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-271] reduce form with (U nil Num) accumulator needs inst to type check Created: 24/Aug/15  Updated: 24/Aug/15

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

Type: Enhancement Priority: Minor
Reporter: Eric Bailey Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Clojure 1.7.0



 Description   

In the example below, the inst shouldn't be needed.

(fn [string :- Str]
  (-> ((inst reduce (U nil Num) Character)
       (fn [sum :- (U nil Num), c :- Character]
         (when sum
           (some-> (case c \1 1, \0 0, nil)
             (+ (* 2 sum)))))
       0 string)
      (or 0)))





[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-269] Combine mutable environments into one atom Created: 11/Aug/15  Updated: 12/Aug/15  Resolved: 12/Aug/15

Status: Resolved
Project: core.typed
Component/s: None
Affects Version/s: None
Fix Version/s: 0.3.11, 0.3.x

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


 Description   

Problem

There are over a dozen atoms containing various type checker state. This should be one map.

Solution

Create clojure.core.typed.env/*checker* atom which stores all checker state in a map.

Pull request: 60
Rebased pull request: 61
Commit: 094738






[CTYP-268] Use clojure.lang.Compiler's analyzer Created: 11/Aug/15  Updated: 11/Aug/15

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

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


 Description   

Problem

The tools.analyzer.jvm analyzer is quite slow, sometimes 3-8x slower than clojure.lang.Compiler.

Solution

Convert the output of clojure.lang.Compiler/analyze to the same format as tools.analyzer.jvm's AST format.

Related: TANAL-113

Pull request: 59






[CTYP-267] bigdec, bigint and biginteger eats (U Number String) Created: 03/Aug/15  Updated: 03/Aug/15

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

Type: Defect Priority: Minor
Reporter: Linus Ericsson Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: bug, typehints


 Description   
(cf bigdec) => [Number -> BigDecimal]

However bigdec can also read strings, like

(bigdec "10.10024") => 10.10024M

bigint and biginteger can also read strings.

The default annotations

clojure.core/bigdec [Number -> BigDecimal]
clojure.core/bigint [Number -> clojure.lang.BigInt]
clojure.core/biginteger [Number -> java.math.BigInteger]

should therefore likely be extended to

[(U Number String) -> ...]





[CTYP-266] Elide checking of ns macro output for performance Created: 02/Aug/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

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

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


 Description   

Problem

Checking the output of the ns macro is very slow.

=> (dotimes [i 3]
     (binding [*ns* *ns*]
       (time (cf (ns foo)))))
"Elapsed time: 527.803116 msecs"
"Elapsed time: 415.179303 msecs"
"Elapsed time: 497.35092 msecs"
nil

tc-ignore'ing the body delivers significant performance enhancements.

;; after patch
=> (dotimes [i 3]
     (binding [*ns* *ns*]
       (time (cf (ns foo)))))
"Elapsed time: 75.241128 msecs"
"Elapsed time: 60.542611 msecs"
"Elapsed time: 57.938648 msecs"
nil

Solution

tc-ignore body of ns macro, with an explicit nil return.

Pull request: 57
Commits: 8ce019d






[CTYP-265] Anonymous functions should rewrite body Created: 01/Aug/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

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

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


 Description   

Commits:






[CTYP-264] deftype should rewrite method bodies Created: 01/Aug/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

Status: Resolved
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: None
Fix Version/s: 0.3.10

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


 Description   

Commits:






[CTYP-263] Unnecessary type hint required in catch expression Created: 27/Jul/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

Status: Resolved
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: 0.3.9
Fix Version/s: 0.3.10, 0.3.x

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


 Description   

Problem

Below is a case where core.typed requires a type hint that Clojure itself doesn't.
(Clojure 1.7, core.typed 0.3.9)

user=> *warn-on-reflection*
true

user=> (try :anything (catch Exception e (.getCause e)))
:anything

user=> (t/cf (try :anything (catch Exception e (.getCause e))))
Type Error (/tmp/form-init1733185424844917450.clj:1:41) Unresolved host interop: getCause

Target java.lang.Exception has no member getCause

Hint: use *warn-on-reflection* to identify reflective calls
in: (. e getCause)

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

Adding a hint satisfies core.typed, but is unnecessary for plain Clojure.

user=> (t/cf (try :anything (catch Exception e (.getCause ^Exception e))))
(t/U (t/Val :anything) nil Throwable)

This used to work without the hint. It first started failing here: (git bisect)

be52bc50cb9f5fd7947d744c5045315ecb0561f1 is the first bad commit
commit be52bc50cb9f5fd7947d744c5045315ecb0561f1
Author: Ambrose Bonnaire-Sergeant <...@gmail.com>
Date:   Wed Jul 1 14:14:13 2015 +0800

    Upgrade tools.analyzer.jvm from 0.4.0 to 0.6.7.

Notes

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

tools.analyzer issue: http://dev.clojure.org/jira/browse/TANAL-112
(already fixed in 0.6.8-SNAPSHOT, see thread)

Solution

Bump t.a.j dep to include 966fe1f and add test.

Pull request: 50
Commits:






[CTYP-262] Accessing keys from a Heterogeneous Map w/ Polymorphic type signature throws type error Created: 24/Jul/15  Updated: 24/Jul/15

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

Type: Defect Priority: Minor
Reporter: Matt Morten Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 1
Labels: None


 Description   

Problem

The following code:

(ann multiply-y-axis (t/All [[x :< Location]] [x -> Number]))
(defn multiply-y-axis [input]
  (let [y (:y input)
        _ (t/ann-form y Number)]
    (* y 2))

...fails with:

Type Error Type mismatch:

Expected: 	Number

Actual: 	t/Any
in: y

Solution

Start investigating how path-type handles free variables. I think it should basically recur
on its upper (or lower?) bound.






[CTYP-261] Typed Transients patch Created: 24/Jul/15  Updated: 28/Jul/15

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

Type: Enhancement Priority: Minor
Reporter: Akhilesh Srikanth Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: enhancement, patch

Attachments: Text File 0001-Added-basic-typechecking-support-for-transients.-Dec.patch    
Patch: Code and Test

 Description   

Problem

Transient collections cannot be used as the core interfaces and functions
lack annotations.

Solution

This patch annotates the ITransient interfaces and the clojure.core transient
functions with tests.

Pull request:
Patch:
Commit:
Release:



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 24/Jul/15 2:54 AM ]

This patch is not rebased properly onto master. I suggest

git fetch origin master
git checkout ctyp-261 ;; or your branch
git rebase master

Please submit a pull request to typedclojure/core.typed for easier review.
I will ask you to submit a patch once I'm satisfied.

The first line of the commit should not wrap, I think you have about 60 characters
to play with. "Added basic typechecking support for transients" is fine.

Then add a paragraph talking about some of the decisions.

  • why are transients covariant
  • what do we assume about transient usage (eg. it's not safe to consider a transient
    covariant if it's bashed in place). Outline cases that are ill-typed if transients
    are covariant

eg.

(let [x (transient [1])] (conj! x nil) (every? zero? (persistent x)))

I'm actually unsure if covariance is the best idea if we don't have uniqueness. But
it would help decide if you motivate covariance.





[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-259] Rewrite function bodies if they are only checked once Created: 23/Jul/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

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

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


 Description   

Problem

We want to rewrite code in the body of functions if they are
only checked once (ie., the functions are not of an intersection
type that overloads the same arities). Currently, function bodies
are not rewritten directly to the respective AST node they originated
from, in case they are checked more than once.

Solution

If an arity is checked only once, then associate the result of type
checking over the old body. Otherwise, keep the current behaviour.

Pull request:
Patch:
Commit:
Release:



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 02/Aug/15 1:41 AM ]

Duplicate of CTYP-247.





[CTYP-258] Correctly simplify negative type propositions in constructor Created: 23/Jul/15  Updated: 23/Jul/15  Resolved: 23/Jul/15

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

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

Attachments: Text File ctyp-258.patch    

 Description   

Problem

The negative type proposition constructor incorrectly simplifies
(! Any ...) to tt instead of (! Nothing ..) to ff.

Solution

Implement and/or test these optimisations:

  • (is Any ..) = tt
  • (is Nothing ..) = ff
  • (! Any ..) = ff
  • (! Nothing ..) = ff

Pull request: 46
Patch: ctyp-258.patch
Commit: 00b8d5
Release: 0.3.9






[CTYP-257] Empty intersection should be Top, not Bottom Created: 23/Jul/15  Updated: 23/Jul/15  Resolved: 23/Jul/15

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

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

Attachments: Text File ctyp-257.patch    

 Description   

Problem

An empty intersection (I) is currently simplified to (U), but it
should be the same as Any.

Solution

Modify the intersection constructors to return Any on empty intersections.

Pull request: 45
Patch: ctyp-257.patch
Commit: 565ff8
Release: 0.3.9






[CTYP-256] Add :unknown implementation to impl-case Created: 22/Jul/15  Updated: 23/Jul/15  Resolved: 23/Jul/15

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

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

Attachments: Text File ctyp-256.patch    

 Description   

Problem

Sometimes we want a default case when no implementation is specified in
impl-case. Since it throws an exception when falling through, we need
an explicit :unknown implementation.

Solution

Add :unknown implementation by default.

Pull request: 44
Patch: ctyp-256.patch
Commit: 856abf
Release: 0.3.9






[CTYP-255] Unparse should be flexible to unknown implementations Created: 22/Jul/15  Updated: 23/Jul/15  Resolved: 23/Jul/15

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

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

Attachments: Text File ctyp-255.patch    

 Description   

Problem

Unparsing a type, often during unit testing via prn, requires the
type system implementation to be specified. This is too restrictive.

Solution

The unknown implementation should verbosely print types, and ignore
the current namespace.

Notes

Implementation extracted from this branch.

Waiting on: CTYP-256
Pull request: 43
Patch: ctyp-255.patch
Commit: 48c225
Release: 0.3.9






[CTYP-254] Add flag to enable AST rewriting Created: 22/Jul/15  Updated: 22/Jul/15  Resolved: 22/Jul/15

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

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

Attachments: Text File ctyp-254.patch    

 Description   

Problem

Since we have both an offline (check-ns) way to type check, and online
(typed REPL), it only makes sense to rewrite the AST in certain cases.

Solution

Add a dynamic variable *can-rewrite* which is true when AST rewriting
makes sense.

Pull request: 41
Patch: ctyp-254.patch
Commit: 9e7b73
Release: 0.3.9






[CTYP-253] Remove static/instance flag in check-method Created: 22/Jul/15  Updated: 22/Jul/15  Resolved: 22/Jul/15

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

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

Attachments: Text File ctyp-253.patch    

 Description   

Problem

The function clojure.core.typed.check.method/check-function takes an extra
argument that can be easily inferred from other arguments.

Solution

Delete the inst? flag and decide whether we have a static/instance method based
on the expression argument.

Pull request: 40
Patch: ctyp-253.patch
Commit: 9a217f
Release: 0.3.9






[CTYP-252] Suppress tools.analyzer's warn-on-reflection Created: 22/Jul/15  Updated: 22/Jul/15  Resolved: 22/Jul/15

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

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

Attachments: Text File ctyp-252.patch    

 Description   

Problem

We use tools.analyzer to analyze code before we emit and send to the standard
Clojure compiler for evaluation. We are planning to rewrite reflective calls,
so we don't want a warning if the initial analysis is reflective, but the final
evaluation is non-reflective.

Solution

Remove the warn-on-reflection pass from tools.analyzer.

Pull request: 39
Patch: ctyp-252.patch
Commit: 7cbc7d
Release: 0.3.9






[CTYP-251] Remove dead code clojure.core.typed.check.fn-method Created: 22/Jul/15  Updated: 22/Jul/15  Resolved: 22/Jul/15

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

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

Attachments: Text File ctyp-251.patch    

 Description   

clojure.core.typed.check.fn-method is dead code, it should be removed.

Pull request: 38
Patch: ctyp-251.patch
Commit: 7ff05e
Release: 0.3.9






[CTYP-250] Resolve Java interoperability based on static type information Created: 21/Jul/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

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

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


 Description   

Problem

Static type information can inform the Clojure compiler of non-reflective
Java interop. With the typed REPL, we now have a means to communicate this
information.

Approach

tools.analyzer.jvm returns :host-interop nodes for unresolved interop.
We first generate type hints based on the static types of the target/argument/
expected type, then passed the type-hinted AST back into the analyzer.

If this doesn't resolve the interop, we throw a type error a usual. If it does,
we type check as usual.

Pull request:

Commit: db3a3






[CTYP-249] Propositional subtyping should consider the lexical type environment Created: 20/Jul/15  Updated: 20/Jul/15

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: refinement-types


 Description   

Problem

Subtyping between propositions could be improved, especially when mixing positive and
negative type propositions.

Take the following function.

; Type Error (clojure/core/typed/test/core.clj:1293:14) Expected result with filter {:then (is Number a__#0), :else tt}, ; got filter {:then (! (t/U nil false) a__#0), :else (is (t/U nil false) a__#0)}
; in: a              |
;                    v
    (is-tc-e (fn [a] a)
             [(U nil Number) -> Any :filters {:then (is Number 0)}])

The subtyping test for the {then} proposition fails because

(! (U nil false) a)

is not a subtype of

(is Number a)

However in the context of the current lexical environment,

{a (U nil Number)}

combined with the actual then proposition

(! (U nil false) a)

implies

(is Number a)
.

Approach

Every {FilterSet} should also carry the {PropEnv} in which it was created. (We should take care that this
environment is substituted properly when we eg. substitute function parameters for de Bruijn indices).

Then we can check to see if the contained environment for the actual proposition set satisfies the
supertype proposition.

Test case:

(is-tc-e (fn [a] a)
             [(U nil Number) -> Any :filters {:then (is Number 0)}])

Notes

This test case should pass: let-filter-unscoping-test.

Code review:
Patch:






[CTYP-248] Move lexical environment to an easily accessible location Created: 20/Jul/15  Updated: 20/Jul/15  Resolved: 20/Jul/15

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

Type: Task Priority: Trivial
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: refinement-types

Attachments: Text File move-lex-env.patch    

 Description   

Problem

To start work on refinement types, we probably want the lexical environment to be easily accessible, especially from type-rep.

Approach

Add a new dynamic variable in util-vars and change existing dereferences of *lexical-env* to a function somewhere.

Code review: CTYP-248
Patch: move-lex-env.patch
Commit: CTYP-248
To appear: 0.3.8






[CTYP-247] Function bodies should rewrite themselves if possible Created: 19/Jul/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

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

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


 Description   

Problem

core.typed resolves some reflective Java interop manually if the
Clojure compiler cannot.

(fn [a :- java.io.File] (.getParent a))

However, in some cases, *warn-on-reflection* still says reflection exists.

This especially happens inside function bodies.

The cause is probably mishandled rewriting of composite AST nodes like :fn
or :do which then drops the rewriting on the floor.

Next steps

Minimal failing case.

Pull request: 49
Commits: Fix+test 488c927






[CTYP-246] Gradually typed namespaces should import untyped vars with a contract Created: 19/Jul/15  Updated: 13/Aug/15

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

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


 Description   

Problem

Gradual typing demands untyped code be protected by contracts. In core.typed,
occurrences of untyped vars in gradually typed code should be changed to add contracts.

For example, importing an untyped number from an untyped namespace should assert we
actually have a number at each dereference of the var.

(ns utyped)
(def n 42)
(ns gtyped
  {:core.typed true}
  (:require [clojure.core.typed :as t])
            [utyped :as utyped]))

(t/ann ^:rt-check utyped/n t/Int)

(inc utyped/n)
;;=> (inc (cast-untyped-var utyped/n))

The question is how to implement cast-untyped-var.

Solution

The first step is to decide on an appropriate way to communicate the
type for untyped vars. We already have :no-check vars for global
annotations, so it seems natural add a :rt-check annotations for
untyped vars whose type we want to enforce at runtime.

The problem of generating specific contracts for specific namespaces
like Typed Racket's require/typed we leave unsolved for now.

Pull request:
Patch:
Commit:
Release:






[CTYP-245] Remove NotTypeFilter Created: 18/Jul/15  Updated: 19/Jul/15

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

Type: Task Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None


 Description   

We have inherited both a positive and negative atomic type proposition
from occurrence typing. Since we have intersection and negation types
in Typed Clojure, we can replace negative type propositions with
positive type propositions on a negated type.

(! (U nil false) x)

becomes

(is (Not (U nil false)) x)

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






[CTYP-244] Filtering with an instantiated identity function doesn't guarantee removal of nil Created: 17/Jul/15  Updated: 17/Jul/15

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

Type: Enhancement Priority: Minor
Reporter: Matt Morten Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: enhancement
Environment:

core.typed 0.3.7, clojure 1.7



 Description   

The following doesn't pass type check:

{{(:require [clojure.core.typed] :as t)
(t/ann filter-that [(t/Seqable (t/U nil Number)) -> (t/Seqable Number)])
(defn filter-that [coll]
(filter (t/inst identity (t/U nil Number)) coll))}}

I would expect the return type of the function to be a collection without the nil type. The error I receive:

Polymorphic function filter could not be applied to arguments:
Polymorphic Variables:
x
y

Domains:
[x -> t/Any] (t/Option (Seqable x))

Arguments:
[(t/U nil Number) -> (t/U nil Number) :filters {:then (! (t/U nil false) 0), :else (is (t/U nil false) 0)} :object {:id 0}] (Seqable (t/U nil Number))

Ranges:
(t/ASeq x)

with expected type:
(t/Seqable Number)

in: (filter (clojure.core.typed/inst-poly identity (quote (#))) coll)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 17/Jul/15 9:49 AM ]

The current workaround for this is to filter on a function with a positive `then` proposition.

eg. (filter number? coll)

Comment by Ambrose Bonnaire-Sergeant [ 17/Jul/15 11:01 AM ]

Changing to enhancement, as current behaviour is not unsound.





[CTYP-243] Dispatch on set of keys Created: 07/Jul/15  Updated: 07/Jul/15

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


 Description   

https://github.com/jgeraerts/imageresizer/blob/master/src/net/umask/imageresizer/resizer.clj#L15






[CTYP-242] adding stop-gap annotation for 'hash-map' results in runtime exception Created: 30/Jun/15  Updated: 30/Jun/15

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

Type: Defect Priority: Minor
Reporter: Jonathan Leonard Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: bug
Environment:

Mac OS X 10.10.3

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

$ lein --version
Leiningen 2.5.1 on Java 1.8.0_45 Java HotSpot(TM) 64-Bit Server VM



 Description   

Adding the following annotation results in a runtime exception:

(t/ann ^:no-check clojure.core/hash-map
     [t/Any * -> (t/Map t/Any t/Any)])

Exception:

$ lein typed check 
Retrieving org/clojure/core.typed/0.3.3/core.typed-0.3.3.pom from central
Retrieving org/clojure/core.typed-pom/0.3.3/core.typed-pom-0.3.3.pom from central
Retrieving org/clojure/core.typed.rt/0.3.3/core.typed.rt-0.3.3.pom from central
Retrieving org/clojure/clojure/1.7.0-RC2/clojure-1.7.0-RC2.pom from central
Retrieving org/clojure/core.typed.rt/0.3.3/core.typed.rt-0.3.3.jar from central
Retrieving org/clojure/core.typed/0.3.3/core.typed-0.3.3.jar from central
Initializing core.typed ...
Building core.typed base environments ...
Exception in thread "main" java.lang.AssertionError: Assert failed: (every? r/Bounds? bbnds), compiling:(/private/var/folders/fg/8xpsfgln1_s0cwh3f1ksxtjr0000gq/T/form-init6446670678682645381.clj:1:124)
	at clojure.lang.Compiler.load(Compiler.java:7142)
	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.AssertionError: Assert failed: (every? r/Bounds? bbnds)
	at clojure.core.typed.type_ctors$TypeFn_STAR_.invoke(type_ctors.clj:1040)
	at clojure.core.typed.type_ctors$TypeFn_STAR_.invoke(type_ctors.clj:1041)
	at clojure.core.typed.base_env_helper$declared_kind_for_rclass.invoke(base_env_helper.clj:179)
	at clojure.core.typed.base_env_clj_rclass$generator_init_altered_env$fn__20119$fn__20125$iter__20126__20130$fn__20131.invoke(base_env_clj_rclass.clj:27)
	at clojure.lang.LazySeq.sval(LazySeq.java:40)
	at clojure.lang.LazySeq.seq(LazySeq.java:49)
	at clojure.lang.RT.seq(RT.java:484)
	at clojure.core$seq.invoke(core.clj:133)
	at clojure.core$dorun.invoke(core.clj:2855)
	at clojure.core$doall.invoke(core.clj:2871)
	at clojure.core.typed.base_env_clj_rclass$generator_init_altered_env$fn__20119$fn__20125.invoke(base_env_clj_rclass.clj:27)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:624)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.core.typed.base_env_clj_rclass$generator_init_altered_env$fn__20119.invoke(base_env_clj_rclass.clj:27)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:624)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.core.typed.base_env_clj_rclass$generator_init_altered_env.invoke(base_env_clj_rclass.clj:25)
	at clojure.core.typed.base_env_clj_rclass$init_altered_env.invoke(base_env_clj_rclass.clj:25)
	at clojure.core.typed.base_env_clj_rclass$reset_rclass_env_BANG_.invoke(base_env_clj_rclass.clj:476)
	at clojure.core.typed.base_env$generator_init_alias_env$fn__20466.invoke(base_env.clj:64)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:624)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.core.typed.base_env$generator_init_alias_env.invoke(base_env.clj:64)
	at clojure.core.typed.base_env$init_alias_env.invoke(base_env.clj:64)
	at clojure.core.typed.base_env$reset_alias_env_BANG_.invoke(base_env.clj:67)
	at clojure.core.typed.base_env$reset_clojure_envs_BANG_$fn__20869$fn__20870.invoke(base_env.clj:1871)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:624)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.core.typed.base_env$reset_clojure_envs_BANG_$fn__20869.invoke(base_env.clj:1870)
	at clojure.core.typed.base_env$reset_clojure_envs_BANG_.invoke(base_env.clj:1870)
	at clojure.core.typed.reset_env$reset_envs_BANG_.invoke(reset_env.clj:20)
	at clojure.core.typed.init$load_impl$fn__1728$fn__1729.invoke(init.clj:113)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:624)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.core.typed.init$load_impl$fn__1728.invoke(init.clj:112)
	at clojure.core.typed.init$load_impl.invoke(init.clj:112)
	at clojure.core.typed.load_if_needed$load_if_needed.invoke(load_if_needed.clj:22)
	at clojure.core.typed$fn__919.invoke(typed.clj:54)
	at clojure.core.typed$fn__1678.doInvoke(typed.clj:2256)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at user$eval1698$fn__1699.invoke(form-init6446670678682645381.clj:1)
	at user$eval1698.invoke(form-init6446670678682645381.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)
	... 11 more
Subprocess failed


 Comments   
Comment by Jonathan Leonard [ 30/Jun/15 2:31 PM ]

The above exception call stack is for version: 0.3.3.

Version 0.3.0-alpha5 produces a different exception call stack:

Exception in thread "main" java.lang.AssertionError: Assert failed: (let [[derived-props derived-atoms] %] (and (every? (some-fn fl/ImpFilter? fl/OrFilter? fl/AndFilter?) derived-props) (every? (some-fn fl/TypeFilter? fl/NotTypeFilter?) derived-atoms))), compiling:(/private/var/folders/fg/8xpsfgln1_s0cwh3f1ksxtjr0000gq/T/form-init3689436395269879959.clj:1:124)
	at clojure.lang.Compiler.load(Compiler.java:7142)
	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.AssertionError: Assert failed: (let [[derived-props derived-atoms] %] (and (every? (some-fn fl/ImpFilter? fl/OrFilter? fl/AndFilter?) derived-props) (every? (some-fn fl/TypeFilter? fl/NotTypeFilter?) derived-atoms)))
	at clojure.core.typed.update$combine_props.invoke(update.clj:58)
	at clojure.core.typed.check.let$check_let$fn__13761$fn__13769.invoke(let.clj:83)
	at clojure.lang.AFn.applyToHelper(AFn.java:154)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:626)
	at clojure.core$update_in.doInvoke(core.clj:5698)
	at clojure.lang.RestFn.invoke(RestFn.java:445)
	at clojure.lang.AFn.applyToHelper(AFn.java:160)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.core$apply.invoke(core.clj:626)
	at clojure.core.contracts.constraints$apply_contract$fn__413.doInvoke(constraints.clj:174)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
	at clojure.lang.RestFn.invoke(RestFn.java:436)
	at clojure.core.typed.check.let$check_let$fn__13761.invoke(let.clj:79)
	at clojure.core.protocols$fn__6086.invoke(protocols.clj:143)
	at clojure.core.protocols$fn__6057$G__6052__6066.invoke(protocols.clj:19)
	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
	at clojure.core.protocols$fn__6078.invoke(protocols.clj:54)
	at clojure.core.protocols$fn__6031$G__6026__6044.invoke(protocols.clj:13)
	at clojure.core$reduce.invoke(core.clj:6289)
	at clojure.core.typed.check.let$check_let.doInvoke(let.clj:103)
	at clojure.lang.RestFn.invoke(RestFn.java:445)
	at clojure.core.typed.check$check _COLON_let14930.doInvoke(check.clj:1629)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at clojure.lang.MultiFn.invoke(MultiFn.java:231)
	at clojure.core.typed.check.do$check_do$fn__12802$fn__12805.invoke(do.clj:41)
	at clojure.core.typed.check.do$check_do$fn__12802.invoke(do.clj:33)
	at clojure.lang.ArrayChunk.reduce(ArrayChunk.java:58)
	at clojure.core.protocols$fn__6093.invoke(protocols.clj:98)
	at clojure.core.protocols$fn__6057$G__6052__6066.invoke(protocols.clj:19)
	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
	at clojure.core.protocols$fn__6078.invoke(protocols.clj:54)
	at clojure.core.protocols$fn__6031$G__6026__6044.invoke(protocols.clj:13)
	at clojure.core$reduce.invoke(core.clj:6289)
	at clojure.core.typed.check.do$check_do.invoke(do.clj:61)
	at clojure.core.typed.check$check _COLON_do14821.doInvoke(check.clj:1382)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at clojure.lang.MultiFn.invoke(MultiFn.java:231)
	at clojure.core.typed.check.fn_method_one$check_fn_method1$fn__13601.invoke(fn_method_one.clj:183)
	at clojure.core.typed.check.fn_method_one$check_fn_method1.doInvoke(fn_method_one.clj:173)
	at clojure.lang.RestFn.invoke(RestFn.java:464)
	at clojure.core.typed.check.special.fn$check_anon$fn__13996.invoke(fn.clj:44)
	at clojure.lang.AFn.applyToHelper(AFn.java:178)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:624)
	at clojure.core$map$fn__4260.invoke(core.clj:2578)
	at clojure.core$map$fn__4245.invoke(core.clj:2559)
	at clojure.lang.LazySeq.sval(LazySeq.java:40)
	at clojure.lang.LazySeq.seq(LazySeq.java:49)
	at clojure.lang.RT.seq(RT.java:484)
	at clojure.core$seq.invoke(core.clj:133)
	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:30)
	at clojure.core.protocols$fn__6078.invoke(protocols.clj:54)
	at clojure.core.protocols$fn__6031$G__6026__6044.invoke(protocols.clj:13)
	at clojure.core$reduce.invoke(core.clj:6289)
	at clojure.core$into.invoke(core.clj:6341)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:626)
	at clojure.core.contracts.constraints$apply_contract$fn__413.doInvoke(constraints.clj:175)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
	at clojure.lang.RestFn.invoke(RestFn.java:421)
	at clojure.core$mapv.doInvoke(core.clj:6360)
	at clojure.lang.RestFn.invoke(RestFn.java:580)
	at clojure.core.typed.check.special.fn$check_anon.invoke(fn.clj:31)
	at clojure.core.typed.check.special.fn$check_special_fn$fn__14110.invoke(fn.clj:206)
	at clojure.core.typed.check.special.fn$check_special_fn.invoke(fn.clj:199)
	at clojure.core.typed.check$fn__14797.invoke(check.clj:1364)
	at clojure.lang.MultiFn.invoke(MultiFn.java:231)
	at clojure.core.typed.check.do$check_do.invoke(do.clj:21)
	at clojure.core.typed.check$check _COLON_do14821.doInvoke(check.clj:1382)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at clojure.lang.MultiFn.invoke(MultiFn.java:227)
	at clojure.core.typed.check.def$check_normal_def.doInvoke(def.clj:61)
	at clojure.lang.RestFn.invoke(RestFn.java:442)
	at clojure.core.typed.check$check _COLON_def14956.doInvoke(check.clj:1673)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at clojure.lang.MultiFn.invoke(MultiFn.java:231)
	at clojure.core.typed.check$check_expr.doInvoke(check.clj:150)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at clojure.core.typed.check$check_asts$iter__14184__14188$fn__14189$fn__14190.invoke(check.clj:119)
	at clojure.core.typed.check$check_asts$iter__14184__14188$fn__14189.invoke(check.clj:118)
	at clojure.lang.LazySeq.sval(LazySeq.java:40)
	at clojure.lang.LazySeq.seq(LazySeq.java:49)
	at clojure.lang.RT.seq(RT.java:484)
	at clojure.core$seq.invoke(core.clj:133)
	at clojure.core$dorun.invoke(core.clj:2855)
	at clojure.core$doall.invoke(core.clj:2871)
	at clojure.core.typed.check$check_asts.invoke(check.clj:118)
	at clojure.core.typed.check.utils$check_ns_and_deps_STAR_.invoke(utils.clj:479)
	at clojure.core.typed.check$check_ns_and_deps.invoke(check.clj:130)
	at clojure.core.typed.check_ns_common$check_ns_info$fn__17011$fn__17012.invoke(check_ns_common.clj:82)
	at clojure.core.typed.check_ns_common$check_ns_info$fn__17011.invoke(check_ns_common.clj:58)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invoke(core.clj:624)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.core.typed.check_ns_common$check_ns_info.doInvoke(check_ns_common.clj:44)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.core$apply.invoke(core.clj:628)
	at clojure.core.typed.check_ns_common$check_ns.doInvoke(check_ns_common.clj:112)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.core$apply.invoke(core.clj:628)
	at clojure.core.typed.check_ns_clj$check_ns.doInvoke(check_ns_clj.clj:23)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at clojure.lang.AFn.applyToHelper(AFn.java:154)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.core$apply.invoke(core.clj:626)
	at clojure.core.typed$fn__2034.doInvoke(typed.clj:2257)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at user$eval7$fn__8.invoke(form-init3689436395269879959.clj:1)
	at user$eval7.invoke(form-init3689436395269879959.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)
	... 11 more
Subprocess failed




[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-240] Annotations for clojure.instant, clojure.template, clojure.set clojure.data and clojure.repl namespaces Created: 25/Jun/15  Updated: 27/Jun/15

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

Type: Enhancement Priority: Minor
Reporter: Aravind K N Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: enhancement

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

 Description   

Annotations for functions in clojure.instant, clojure.template, clojure.set clojure.data and clojure.repl namespaces were added






[CTYP-239] Search for .cljc files when checking a namespace Created: 25/Jun/15  Updated: 31/Aug/15

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

Type: Enhancement Priority: Minor
Reporter: Alejandro Assignee: Alejandro
Resolution: Unresolved Votes: 0
Labels: readerconditionals

Attachments: Text File 0001-CTYP-239-Search-for-.cljc-files-when-checking-a-name.patch    
Patch: Code
Waiting On: Ambrose Bonnaire-Sergeant

 Description   

Currently core.typed assumes that Clojure files end with a .clj extension and ClojureScript files with .cljs. However, due to the introduction of reader conditionals to the language the .cljc extension is now valid for both Clojure and ClojureScript. core.typed should look for .cljc files in addition to .clj and .cljs.

The problem originates in the clojure.core.typed.coerce-utils namespace's ns->file function, since it hardcodes the .clj and .cljs extensions for finding Clojure and ClojureScript namespaces. When using this function from clojure.core.typed.analyze-clj namespace's ast-for-ns function it throws an exception.

Pull request: 58



 Comments   
Comment by Alejandro [ 25/Jun/15 9:38 AM ]

Since the current version of tools.analyzer.jvm that core.typed depends on doesn't support .cljc files the patch can't be applied yet.

Comment by Ambrose Bonnaire-Sergeant [ 19/Jul/15 11:16 AM ]

The latest tools.analyzer.jvm is inlined at clojure.core.typed.deps.clojure.tools.analyzer.jvm (see project.clj for the version).

Can this now move forward?

Comment by Brendan Tobolaski [ 31/Aug/15 1:47 PM ]

I see that there is a pull request for this on GitHub but it doesn't appear to have been merged onto master yet. Is this waiting on anything in particular?

Comment by Ambrose Bonnaire-Sergeant [ 31/Aug/15 2:18 PM ]

I'd merge if there was a test.





[CTYP-238] Move CLJS checker to its own jar Created: 24/Jun/15  Updated: 24/Jun/15

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

Type: Task Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None





[CTYP-237] Convert .clj files to .cljc Created: 24/Jun/15  Updated: 24/Jun/15

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

Type: Task Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None





[CTYP-236] Refactor core.async annnotations into its own jar Created: 24/Jun/15  Updated: 24/Jun/15

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

Type: Task Priority: Trivial
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None





[CTYP-235] Warn on duplicate defalias' Created: 24/Jun/15  Updated: 20/Jul/15

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: errormsgs, newbie


 Description   

Defining an alias with the different types should yield a warning.

This should say

(defalias F Any)
(defalias F Int)
;; WARNING: Type alias user/F changed. Old: Any, New: Int

However, if the annotations are = after parse-type, then it should not give a warning.

(defalias G Int)
(defalias G Int)
;; <No warning>





[CTYP-234] Setting :collect-only attribute for a namespace does not collect type aliases Created: 23/Jun/15  Updated: 21/Jul/15  Resolved: 21/Jul/15

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

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

Tested with 0.3.0-alpha5


Attachments: Text File ctyp-234.patch    
Patch: Code and Test

 Description   

Problem

Adding the {:core.typed {:collect-only true}} attribute to a namespace prevents core.typed from collecting any type aliases defined via defalias in that namespace.

E.g.

(ns collect-only-bug.other
  {:core.typed {:collect-only true}}
  (:require [clojure.core.typed :as t]))

(t/defalias MyType (t/HMap :mandatory {:foo String
                                       :bar t/AnyInteger}))
(ns collect-only-bug.core
  (:require [clojure.core.typed :as t]
            [collect-only-bug.other :as other]))

(t/ann foo [other/MyType -> t/AnyInteger])
(defn foo
  [x]
  (:bar x))
user=> (t/check-ns 'collect-only-bug.core)
Start collecting collect-only-bug.core
Finished collecting collect-only-bug.core
Collected 1 namespaces in 218.520311 msecs
Not checking clojure.core.typed (does not depend on clojure.core.typed)
Not checking collect-only-bug.other (tagged :collect-only in ns metadata)
Start checking collect-only-bug.core
Type Error (collect_only_bug/core.clj:8:9) Internal Error (collect_only_bug/core.clj:8:3) Cannot resolve name collect-only-bug.other/MyType

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

Solution

Add a new predicate should-collect-ns? and use it in collect-phase
to pick namespaces to collect.

Pull request: 33
Patch: ctyp-234.patch (some trailing whitespace)
Commit: 773291
Release: 0.3.8



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 24/Jun/15 8:16 AM ]

Started work here: https://github.com/typedclojure/core.typed/pull/10





[CTYP-233] Java interop should consider automatic numeric promotions Created: 23/Jun/15  Updated: 23/Jun/15

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


 Description   

`(Math/pow 2 3)` doesn't type check, since it's inferred as [double double -> double], but
(cf 2 double) fails.

Some rules:
https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.6

Also see Reflector.paramArgTypeMatch()






[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-231] (Array X) is broken and undocumented Created: 23/Jun/15  Updated: 20/Jul/15

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

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


 Description   

There is no documentation about (Array X) in the API docs: http://clojure.github.io/core.typed/#clojure.core.typed - it was hard to find our that such a thing existed.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 23/Jun/15 8:26 AM ]

Unfortunately it's intentional. It's a long standing issue, one that I've thought long and hard about, but Arrays broken right now. The main problem is that there is no distinction between an array of boxed values and an array of unboxed values – you can upcast from one the other.

I will put this near the top of the list of things to do.

Comment by Marc O'Morain [ 23/Jun/15 8:39 AM ]

We have a few uses of Array in our code-base. The few I have been touching today are for annotating clojure.java.io signatures. We don't use the byte[] forms of the functions at present, so we should be OK for now.

Thanks

Comment by Ambrose Bonnaire-Sergeant [ 23/Jun/15 8:50 AM ]

The implementation is fast and loose about the distinction of byte and Byte too – they're pretty much identical, since Clojure does the appropriate coercions at runtime. Also be careful about that.





[CTYP-230] Improve error messages by highlighting unmatched argument Created: 22/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: Minor
Reporter: Marc O'Morain Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I'm currently trying to fix a couple of type errors with the following form, and it's very difficult to find which argument is not matching the type signature.

Type Error (circle/backend/action/bash.clj:315:32) Function bash could not be applied to arguments:


Domains:
	circle.util.type.ann/BuildRef t/Any (t/U sh/SteveExpr sh/SteveOneLiner) (t/HMap :optional {:background Boolean})

Arguments:
	(Ref circle.util.type.ann/BuildNode circle.util.type.ann/BuildNode) t/Any (t/U sh/SteveExpr sh/SteveOneLiner) (t/HMap :mandatory {:bash-command String, :name t/Any} :optional {:environment sh/EnvMap, :pwd String, :circle-bug-on-fail Boolean})

Ranges:
	t/Any

with expected type:
	t/Any

From inspection I can see that the second and third parameters seem OK, since they are have expanded to the same string, but core.typed does not tell me if the problem is with the first, fourth, or both arguments.



 Comments   
Comment by Marc O'Morain [ 22/Jun/15 5:10 PM ]

I submitted to soon and I don't seem to have edit permission – I was going to suggest that the error message include the argument index of the failing type-check, and print the expected and given types as an extra message. It would be even better if you could pull out the parameter name given when the function is defined:

Argument 1 `build` does not match type annotation:
  Expected `circle.util.type.ann/BuildRef`
  Given `(Ref circle.util.type.ann/BuildNode circle.util.type.ann/BuildNode)`




[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-227] Show file and line number of duplicate definitions Created: 18/Jun/15  Updated: 18/Jun/15

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

Type: Enhancement Priority: Minor
Reporter: Marc O'Morain Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

[org.clojure/core.typed "0.3.0-alpha2" :classifier "slim"]



 Description   

When we check types in CircleCI we get warning like this:

WARNING: Duplicate var annotation: clojure.core/group-by

Core.typed does not tell us where the duplicate definitions are located. It would be great if the type checker could print the file and line number of the definitions when this warning is printed.

WARNING: foo.clj:35 Duplicate var annotation: clojure.core/group-by Previous definition in bar.clj:56



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 18/Jun/15 10:18 AM ]

We should be able to store line information about the last annotation as metadata on the var symbol used as a key in clojure.core.typed.var-env.





[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-221] group-by produces "Cannot resolve type: Seqable" Created: 29/May/15  Updated: 29/May/15

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

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


 Description   

How to reproduce:

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 56675 on host 127.0.0.1 - nrepl://127.0.0.1:56675
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/defn repro-core-typed-9 [m :- (t/Seqable String)] (group-by identity m)))
Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 10484.613659 msecs"
core.typed initialized.
DEPRECATED SYNTAX (NO_SOURCE_PATH): All syntax is deprecated, use clojure.core.typed/All
DEPRECATED SYNTAX (NO_SOURCE_PATH): U syntax is deprecated, use clojure.core.typed/U
Type Error (NO_SOURCE_PATH:1:60) Internal Error (NO_SOURCE_PATH:1:60) Cannot resolve type: Seqable
Hint: Is Seqable in scope?
Hint: Has Seqable's annotation been found via check-ns, cf or typed-deps?
Error
user=>

Expected result:

Should not give an internal error.

Note:

core.typed rules! I'm finding it very useful for my project and has found many bugs before they hit production--it's a great tool to have access to.






[CTYP-220] Data generator for a type 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: Minor
Reporter: victor chung Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I would like to have a function gen-data which, given any type, generates a random instance of that type.
For example, we have a type:

(t/defalias Move
"A legal move in rock-paper-scissors"
(t/U ':rock ':paper ':scissors))

then (gen-data Move) would give any of :rock :paper or :scissors.



 Comments   
Comment by victor chung [ 22/May/15 3:59 AM ]

This is useful when you are doing exploratory things in a repl.

Comment by Ambrose Bonnaire-Sergeant [ 22/May/15 4:05 AM ]

Is there a test.check or data.generators API we can reuse?





[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-217] Basic support for transients Created: 17/May/15  Updated: 17/May/15

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

Type: Enhancement Priority: Minor
Reporter: Akhilesh Srikanth Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: enhancement, patch

Attachments: Text File 0001-decided-to-use-covariants-on-transient-types.patch     Text File 0002-added-basic-annotations-for-assoc-and-dissoc.patch     Text File 0003-added-basic-transient-data-structure-tests.patch     Text File 0004-added-more-tests.patch     Text File 0005-added-basic-dissoc-tests.patch     Text File 0006-added-annotations-for-core-transient-functions.patch    
Patch: Code and Test
Approval: Triaged

 Description   

This patch adds basic support for type checking transient data structures and involves annotations for core data structures (transient vectors, sets, maps, etc) and functions (assoc!, conj!, pop!, disj!) along with tests for the functions.






[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-215] Domain of clojure.core/zero? is Number, not Any Created: 23/Apr/15  Updated: 18/May/15  Resolved: 18/May/15

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

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


 Description   

The annotation for clojure.core/zero? gives its type as [Any -> Boolean], but calling it with anything other than a number results in a ClassCastException. The type should probably be something like:

[Number -> Boolean :filters {:then (is (t/Val 0) 0)
                             :else (! (t/Val 0) 0)}]


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 18/May/15 3:48 AM ]

Fixed annotation for zero? and inlining for 0.2.89.

https://github.com/clojure/core.typed/commit/2121d252454283140bad8d263e7bd9883aaca00d





[CTYP-214] core.typed 0.2.84 raises an exception when trying to infer the type of (atom #{}) Created: 22/Apr/15  Updated: 24/Jun/15  Resolved: 24/Jun/15

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

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

Java 1.8



 Description   

Setup core.typed, for example

$ lein try org.clojure/core.typed "0.2.84"

and then simply execute

user=> (require 'clojure.core.typed)
nil
user=> (clojure.core.typed/cf (atom #{}))
Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 4622.004619 msecs"
core.typed initialized.
IllegalArgumentException No value supplied for key: true clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)

Here's the whole stacktrace

java.lang.IllegalArgumentException: No value supplied for key: true
      PersistentHashMap.java:77 clojure.lang.PersistentHashMap.create
               type_rep.clj:614 clojure.core.typed.type-rep/-hset
                RestFn.java:423 clojure.lang.RestFn.invoke
         promote_demote.clj:221 clojure.core.typed.promote-demote/fn[fn]
         promote_demote.clj:218 clojure.core.typed.promote-demote/fn
               MultiFn.java:231 clojure.lang.MultiFn.invoke
          promote_demote.clj:49 clojure.core.typed.promote-demote/promote-var
                cs_gen.clj:1090 clojure.core.typed.cs-gen/promote-F
                cs_gen.clj:1116 clojure.core.typed.cs-gen/cs-gen-right-F
                 cs_gen.clj:328 clojure.core.typed.cs-gen/cs-gen[fn]
                 cs_gen.clj:316 clojure.core.typed.cs-gen/cs-gen
                cs_gen.clj:1594 clojure.core.typed.cs-gen/cs-gen-list[fn]
                LazySeq.java:40 clojure.lang.LazySeq.sval
                LazySeq.java:49 clojure.lang.LazySeq.seq
                    RT.java:484 clojure.lang.RT.seq
                   core.clj:133 clojure.core/seq
                  core.clj:2855 clojure.core/dorun
                  core.clj:2871 clojure.core/doall
                cs_gen.clj:1592 clojure.core.typed.cs-gen/cs-gen-list
                RestFn.java:587 clojure.lang.RestFn.invoke
                cs_gen.clj:1747 clojure.core.typed.cs-gen/infer
                 funapp.clj:277 clojure.core.typed.check.funapp/check-funapp[fn]
                 funapp.clj:202 clojure.core.typed.check.funapp/check-funapp[fn]
                 funapp.clj:192 clojure.core.typed.check.funapp/check-funapp[fn]
                  funapp.clj:52 clojure.core.typed.check.funapp/check-funapp
                  invoke.clj:13 clojure.core.typed.check.invoke/normal-invoke
                RestFn.java:587 clojure.lang.RestFn.invoke
                 check.clj:1294 clojure.core.typed.check/check -COLON-invoke17233[fn]
                 check.clj:1273 clojure.core.typed.check/check -COLON-invoke17233
                RestFn.java:423 clojure.lang.RestFn.invoke
               MultiFn.java:231 clojure.lang.MultiFn.invoke
                  check.clj:151 clojure.core.typed.check/check-expr
                RestFn.java:423 clojure.lang.RestFn.invoke
       check_form_common.clj:40 clojure.core.typed.check-form-common/check-form-info[fn]
       check_form_common.clj:37 clojure.core.typed.check-form-common/check-form-info[fn]
                   AFn.java:152 clojure.lang.AFn.applyToHelper
                   AFn.java:144 clojure.lang.AFn.applyTo
                   core.clj:624 clojure.core/apply
                  core.clj:1862 clojure.core/with-bindings*
                RestFn.java:425 clojure.lang.RestFn.invoke
       check_form_common.clj:25 clojure.core.typed.check-form-common/check-form-info
                RestFn.java:521 clojure.lang.RestFn.invoke
       check_form_common.clj:61 clojure.core.typed.check-form-common/check-form*
          check_form_clj.clj:22 clojure.core.typed.check-form-clj/check-form*
                 typed.clj:2155 clojure.core.typed/check-form*
                 typed.clj:2151 clojure.core.typed/check-form*
               NO_SOURCE_FILE:1 user/eval13925
             Compiler.java:6703 clojure.lang.Compiler.eval
             Compiler.java:6666 clojure.lang.Compiler.eval
                  core.clj:2927 clojure.core/eval
                   main.clj:239 clojure.main/repl[fn]
                   main.clj:239 clojure.main/repl[fn]
                   main.clj:257 clojure.main/repl[fn]
                   main.clj:257 clojure.main/repl
               RestFn.java:1523 clojure.lang.RestFn.invoke
      interruptible_eval.clj:67 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
                   AFn.java:152 clojure.lang.AFn.applyToHelper
                   AFn.java:144 clojure.lang.AFn.applyTo
                   core.clj:624 clojure.core/apply
                  core.clj:1862 clojure.core/with-bindings*
                RestFn.java:425 clojure.lang.RestFn.invoke
      interruptible_eval.clj:51 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
     interruptible_eval.clj:183 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
     interruptible_eval.clj:152 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
                    AFn.java:22 clojure.lang.AFn.run
   ThreadPoolExecutor.java:1142 java.util.concurrent.ThreadPoolExecutor.runWorker
    ThreadPoolExecutor.java:617 java.util.concurrent.ThreadPoolExecutor$Worker.run
                Thread.java:745 java.lang.Thread.run

note that `(cf #{})`, or `(cf (atom {}))` or other variants all work. It only seems to be a problem with `(atom #{})`.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 24/Jun/15 11:54 AM ]

Fixed in 0.3.0 https://github.com/clojure/core.typed/commit/a9018f68e997ceb076bb146efe1bff0d8231f037





[CTYP-213] core.typed 0.2.87 fails in combination with org.clojure/tools.analyzer.jvm 0.6.5 on Clojure 1.6 Created: 21/Apr/15  Updated: 20/Jul/15  Resolved: 20/Jul/15

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

Type: Defect Priority: Major
Reporter: Jakub Arnold Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 1
Labels: None
Environment:

Clojure 1.6.0, Java 8, OS X 10.10.3



 Description   

To reproduce, simply run

$ lein try org.clojure/core.typed "0.2.87" org.clojure/tools.analyzer.jvm "0.6.5" org.clojure/clojure "1.6.0"

and then basically any attempt to use core.typed will fail with the same error, for example

user=> (require '[clojure.core.typed :as t])
nil
user=> (t/cf 1)
Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 16052.550743 msecs"
core.typed initialized.

UnsupportedOperationException nth not supported on this type: Long clojure.lang.RT.nthFrom (RT.java:857)

note that there are similar combinations of versions that do work, such as

$ lein try org.clojure/core.typed "0.2.84" org.clojure/tools.analyzer.jvm "0.6.5" org.clojure/clojure "1.6.0"



 Comments   
Comment by Jakub Arnold [ 21/Apr/15 7:04 PM ]

Here are a few more detailed logs of different scenarios

broken `lein try org.clojure/core.typed "0.2.87" org.clojure/tools.analyzer.jvm "0.6.5" org.clojure/clojure "1.6.0"`
https://gist.github.com/darthdeus/5f3a40cdff8e21eed15d

working `lein try org.clojure/core.typed "0.2.84" org.clojure/tools.analyzer.jvm "0.6.6"` https://gist.github.com/darthdeus/6a3a7f5fb91073575f77

possibly related issue on `lein try org.clojure/core.typed "0.2.87" org.clojure/tools.analyzer.jvm "0.6.6"`
https://gist.github.com/darthdeus/88b5b8f94fafdb85d81f

and the original issue with a full stacktrace https://gist.github.com/darthdeus/1a071c829e2aa4b96a09

Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/15 11:11 PM ]

core.typed 0.3.7 now depends on tools.analyzer 0.6.5 and Clojure 1.7.0.





[CTYP-212] Can't create a promise of the same type as a record field Created: 20/Apr/15  Updated: 21/Jul/15  Resolved: 21/Jul/15

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

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

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


Attachments: Text File ctyp-212.patch    
Patch: Code and Test

 Description   

Problem

It seems to be impossible to create a promise of the same type as a record field:

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

(t/ann-record MyRecord [p :- (t/Promise int)])

(defrecord MyRecord [p])

(defn foo []
  (t/let [x :- (t/Promise int) (promise)]))

; Type Error (cttest/core.clj:9:32) Polymorphic function promise could not be applied to arguments:
; Polymorphic Variables:
;         x
;
; Domains:
;
;
; Arguments:
;
;
; Ranges:
;         (t/Promise x)
;
; with expected type:
;         (t/Promise int)
;
; in: (promise)
; in: (promise)

Changing the type of p in MyRecord to any other type, say (t/Promise String) makes foo pass the type checker.

Solution

This seems to have been fixed sometime between 0.2.84 and 0.3.7. Adding a
passing unit test to close this issue.

Pull request: 30
Patch: ctyp-212.patch
Commit: 2c00a3f
Release: 0.3.8



 Comments   
Comment by Timo Mihaljov [ 20/Apr/15 11:36 PM ]

I hit the save button too soon. I couldn't reproduce this in a clean project, so there's something else going on in my project that's causing this. I might reopen the issue once I've narrowed down what's causing it.

Comment by Timo Mihaljov [ 22/Apr/15 12:39 AM ]

The difference was that the test project was missing the record. I've reopened the issue now that it's reproducible.





[CTYP-211] First check-ns fails with Cannot resolve type: cljs.core/ICloneable Created: 09/Apr/15  Updated: 16/Apr/15  Resolved: 16/Apr/15

Status: Closed
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: Not Reproducible Votes: 0
Labels: None
Environment:

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



 Description   

When I call check-ns for the first time in a new REPL, it fails with
Cannot resolve type: cljs.core/ICloneable. The following runs work as
expected.

Here is a REPL session demonstrating the problem:

lein repl
nREPL server started on port 52763 on host 127.0.0.1 - nrepl://127.0.0.1:52763
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_25-b17
    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

reiska.core=> (require '[clojure.core.typed :as t])
nil
reiska.core=> (t/check-ns 'reiska.tiling) ; <===== FIRST RUN =====
Initializing core.typed ...
Found ClojureScript, loading ...
Finished loading ClojureScript
Building core.typed base environments ...
DEPRECATED SYNTAX (NO_SOURCE_PATH): Rec syntax is deprecated, use cljs.core.typed/Rec
DEPRECATED SYNTAX (NO_SOURCE_PATH): HVec syntax is deprecated, use cljs.core.typed/HVec

ExceptionInfo Internal Error (:<NO LINE>) Cannot resolve type: cljs.core/ICloneable
Hint: Is cljs.core/ICloneable in scope?
Hint: Has cljs.core/ICloneable's annotation been found via check-ns, cf or typed-deps?  clojure.core/ex-info (core.clj:4403)
reiska.core=> (t/check-ns 'reiska.tiling) ; <===== SECOND RUN =====
Start collecting reiska.tiling
Finished collecting reiska.tiling
Collected 1 namespaces in 1961.041822 msecs
Not checking primitive-math (does not depend on clojure.core.typed)
Not checking clojure.core.typed (does not depend on clojure.core.typed)
Not checking clojure.core.typed.unsafe (does not depend on clojure.core.typed)
Not checking reiska.renderer (does not depend on clojure.core.typed)
Start checking reiska.tiling
30:  Not checking reiska.tiling/->Tiling definition
WARNING:  RClass ancestor for clojure.lang.Agent defaulting to most general parameters :  clojure.lang.ARef
WARNING:  RClass ancestor for clojure.lang.Agent defaulting to most general parameters :  clojure.lang.ARef
WARNING:  RClass ancestor for clojure.lang.Agent defaulting to most general parameters :  clojure.lang.ARef
Checked reiska.tiling in 4063.554165 msecs
Checked 5 namespaces  in 6050.510933 msecs
:ok
reiska.core=>


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Apr/15 1:21 PM ]

Can you post your project.clj, in particular the CLJS version you're using?

Comment by Timo Mihaljov [ 09/Apr/15 11:11 PM ]

I'm not using CLJS, so it's not on the classpath at all.

Comment by Timo Mihaljov [ 15/Apr/15 11:14 PM ]

This bug prevents the use of lein-typed, because lein typed check always does this first, failing run.

Comment by Ambrose Bonnaire-Sergeant [ 16/Apr/15 4:38 PM ]

I can't reproduce. Please post the output of `lein deps :tree` and a github project I can clone and reproduce.

Comment by Timo Mihaljov [ 16/Apr/15 11:06 PM ]

Turns out one of my dependencies, Quil, transitively depended on an old version of ClojureScript [org.clojure/clojurescript "0.0-2080"]. Sorry about the invalid report, I'll make sure to come up with a clean reproduction the next time.





[CTYP-210] (long AnyInteger) doesn't typecheck Created: 08/Apr/15  Updated: 22/Jul/15  Resolved: 22/Jul/15

Status: Resolved
Project: core.typed
Component/s: None
Affects Version/s: None
Fix Version/s: 0.3.9, 0.3.x

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

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


Attachments: Text File ctyp-210.patch    

 Description   
reiska.core=> (t/cf (long (+ 2 (int 123))))
Type Error (/private/var/folders/x2/47j5hlbs01b9b4mjz_8fyf05m8hy4p/T/form-init7340610759194794514.clj:1:7) Static method clojure.lang.RT/longCast could not be applied to arguments:


Domains:
        long

Arguments:
        t/AnyInteger

Ranges:
        long

in: (clojure.lang.RT/longCast (clojure.lang.Numbers/add 2 (clojure.lang.RT/intCast 123)))
in: (clojure.lang.RT/longCast (clojure.lang.Numbers/add 2 (clojure.lang.RT/intCast 123)))


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

Pull request: 36
Patch: ctyp-210.patch
Commit: 68d20b
Release: 0.3.9



 Comments   
Comment by Timo Mihaljov [ 14/Apr/15 10:57 PM ]

Here's what I think is going on:

1. clojure.core/long is defined as an inlineable function, so its body gets inlined and core.typed never sees the function application (long x) (where long's type is [t/Any -> Long]). Instead, it sees the method application (clojure.lang.RT/longCast x) and has to infer the method's type from its Java type.

This hypothesis is supported by the following experiment. Commenting out the inline form in a copy of clojure.core/long makes it apply cleanly to t/AnyInteger values.

;;; Doesn't typecheck

(t/ann ^:no-check my-long [t/Any -> long])
(defn my-long
  {:inline (fn [x] `(. clojure.lang.RT (longCast ~x)))}
  [^Number x]
  (clojure.lang.RT/longCast x))

(def a (my-long (t/ann-form 123 t/AnyInteger)))
;;; Typechecks

(t/ann ^:no-check my-long2 [t/Any -> long])
(defn my-long2
  ; Commented out: {:inline (fn [x] `(. clojure.lang.RT (longCast ~x)))}
  [^Number x]
  (clojure.lang.RT/longCast x))

(def b (my-long2 (t/ann-form 123 t/AnyInteger)))

2. The clojure.lang.RT/longCast method is overloaded. It seems that instead of inferring a multi-arity type, core.typed seems to pick just one of the arities. In this case it picks the wrong arity: t/AnyInteger is a valid argument to longCast(Object x), but not the picked longCast(long x).





[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-207] Equality Propositions Created: 13/Mar/15  Updated: 18/May/15  Resolved: 18/May/15

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   
(is-tc-e (fn [a :- Any, b :- Boolean, c :- Int]
             (let [x (if (number? a)
                       b
                       c)]
               (if (number? a)
                 (not x)
                 (inc x)))))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 18/May/15 4:06 AM ]

Let-aliasing handles this.





[CTYP-206] Fixed as rest args Created: 13/Mar/15  Updated: 13/Mar/15

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


 Description   
(is-tc-e (fn
             ([& [a]] a))
           [x :- Any -> Any :object {:id 0}])





[CTYP-205] Better filter checking Created: 13/Mar/15  Updated: 13/Mar/15

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


 Description   

(deftest apple-test
(is-tc-e (do
(ann-datatype [[t :variance :covariant]] Apple [a :- Int])
(deftype Apple [a])
(defalias WaApple (U (Apple 'good) (Apple 'awesome)))
(defalias NWFood (U WaApple 'salmon))
(ann eat? [NWFood -> Boolean :filters {:then (is WaApple 0)
:else (! WaApple 0)}])
(defn eat? [w]
(instance? Apple w)))))






[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-203] Unreproducable internal error Created: 09/Mar/15  Updated: 21/Jul/15  Resolved: 21/Jul/15

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

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

osx yosemite, jdk 7


Attachments: Text File ctyp-203.patch    
Patch: Code and Test

 Description   

Problem

It is unclear how to reproduce, but this is the original report.

The following REPL shows the problem:

(t/defalias BaseValidationSchema
            '[java.lang.Boolean (t/HMap :complete? false)])

=> nil
(t/cf [true {}] BaseValidationSchema)
Type Error (NO_SOURCE_FILE) Internal Error (:<NO LINE>) Wrong number of arguments passed to type function. Expected 1, actual 2: clojure.core.typed/Vec [java.lang.Boolean (clojure.core.typed/HMap :mandatory {})]
ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.clj:4403)
(t/cf [true {}] '[java.lang.Boolean (t/HMap :complete? false)])
=> [(t/HVec [true (t/HMap :complete? true)]) {:then tt, :else ff}]

From https://groups.google.com/d/msg/clojure-core-typed/uX2v9wbwTwI/yyErih2cPDMJ

Solution

Add passing unit test since we cannot reproduce.

Pull request: 34
Patch: ctyp-203.patch
Commit: 372108
Release: 0.3.8






[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-200] min and max function are inferred to return java.long.Number if all parameters are Integer Created: 24/Feb/15  Updated: 18/May/15  Resolved: 18/May/15

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

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


 Description   

If all arguments to min/max are the same type, it should be inferred to return that type.

user.core=> (t/cf (t/fn [a :- Integer b :- Integer] (min a b)))
[[java.lang.Integer java.lang.Integer -> java.lang.Number] {:then tt, :else ff}]
user.core=> (t/cf (t/fn [a :- Integer b :- Integer] (max a b)))
[[java.lang.Integer java.lang.Integer -> java.lang.Number] {:then tt, :else ff}]

This leads to issues when I try to pass the return value of min/max as an argument of a function that expects Integer types.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 01/Mar/15 7:33 PM ]

What should this return?

Comment by Reno Reckling [ 02/Mar/15 2:24 AM ]

The min/max of two or more integers should be Integer and not Number.

Comment by Reno Reckling [ 02/Mar/15 2:33 AM ]

Example code:

=> (t/cf (t/let [mfn :- (t/IFn [Integer Integer -> Integer]) (fn [x y] (min x y))] (mfn 4 5)))
Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 3174.574343 msecs"
core.typed initialized.
Type Error (init.clj:1:69) Type mismatch:

Expected:       java.lang.Integer

Actual:         java.lang.Number
in: (clojure.lang.Numbers/min x y)
Comment by Reno Reckling [ 02/Mar/15 3:57 AM ]

The expected type in general would be the union type of all arguments but i don't think there is a syntax for this yet:

(min Long Float BigDecimal) should have the return type (U Long Float BigDecimal) with the constraint that all types are subtypes of Number

Comment by Ambrose Bonnaire-Sergeant [ 18/May/15 5:38 AM ]

Fixed for 0.2.89 https://github.com/clojure/core.typed/commit/3026d3a8d4e519c15f13bb55782128c030d360f4





[CTYP-199] incorrect typing for group-by Created: 24/Feb/15  Updated: 03/Mar/15  Resolved: 03/Mar/15

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

Type: Defect Priority: Major
Reporter: Martin Raison Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug
Environment:

Using 0.2.80


Attachments: Text File CTYP-199.patch    

 Description   

It seems that group-by is incorrectly annotated. For example:

(cf (group-by even? [1 2 2]))

will return

(Map Boolean (U (Val 1) (Val 2)))

However the group-by operation returns

{false [1], true [2 2]}

so I think the type should be:

(Map Boolean (Vec (U (Val 1) (Val 2))))



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

Patch to solve this.
Sorry, did not see the upload button on my first comment...

Comment by Ambrose Bonnaire-Sergeant [ 03/Mar/15 10:34 AM ]

Reno, I think you need to set an email for your local git.

Fixed https://github.com/clojure/core.typed/commit/78f4b5d58d712d9b67738a807aadcec641638078





[CTYP-198] incorrect optional keyword lookup in complete HMaps Created: 12/Feb/15  Updated: 22/Jul/15  Resolved: 22/Jul/15

Status: Closed
Project: core.typed
Component/s: Core type system
Affects Version/s: 0.2
Fix Version/s: 0.2

Type: Defect Priority: Major
Reporter: Nathan Sorenson Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug, patch
Environment:

Clojure 1.6.0 on OSX 10.10


Attachments: Text File 0001-tests-for-keyword-lookup-in-HMaps-with-optional-keys.patch     Text File 0002-fix-incorrect-optional-keyword-lookup-in-complete-HM.patch    
Patch: Code and Test

 Description   

Problem

The snippet

(t/cf (:name (t/ann-form {:name "hi"} (t/HMap :optional {:name String} :complete? true))))

returns nil when it probably should return (t/U String nil)

Commit:
1. e27143
2. f3713b
Release: 0.2.79






[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-196] `frees` for `NthPE` is missing Created: 17/Jan/15  Updated: 07/Feb/15  Resolved: 07/Feb/15

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   

lein typed check sicp.debug for

(ns sicp.debug
  (:require [clojure.core.typed]))

(let [a first]
  a)

causes

No method in multimethod 'frees' for dispatch value: [:clojure.core.typed.frees/frees clojure.core.typed.path_rep.NthPE]


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 07/Feb/15 3:06 PM ]

Fixed in 0.2.78 https://github.com/clojure/core.typed/commit/e8c8785509ea4936e5ed969e5684c7285644e9f1





[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-193] core.typed breaks some applications on Clojure 1.7.0-alpha5 due to JAR including AOT-compiled core.cache and core.memoize Created: 12/Jan/15  Updated: 18/Apr/15  Resolved: 18/Apr/15

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

Type: Defect Priority: Blocker
Reporter: Sean Corfield Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 1
Labels: None


 Description   

See this ticket for more details: http://dev.clojure.org/jira/browse/CLJ-1639

Since the Clojure behavior has been deemed correct, I'm opening the bug against core.typed since it is the inclusion of AOT-compiled core.cache and core.memoize that caused this problem.

For now, we have stripped core.typed out of our code base completely so that we can stay current on Clojure builds.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 14/Jan/15 4:48 AM ]

The slim jar might temporarily fix this issue: https://github.com/clojure/core.typed#releases-and-dependency-information

core.typed shouldn't be doing this and it's a defect, but I don't know how to configure Maven to exclude third-party AOT namespaces (I've tried multiple times, never seems to work). Patch welcome.

Comment by Alex Miller [ 16/Jan/15 2:14 PM ]

I will try to help with this next week.

Comment by Alex Miller [ 16/Jan/15 2:18 PM ]

Ambrose, do you want AOT-compiled classes to appear in the output jar or do you just want compilation to occur during the build?

Comment by Ambrose Bonnaire-Sergeant [ 16/Jan/15 7:29 PM ]

Alex, I want to strip the org.clojure/core.typed jar of AOT-compiled classes that occur outside of clojure/core/typed. I originally tried to do this after the AOT compilation manually with Maven.

Comment by Herwig Hochleitner [ 26/Feb/15 10:06 PM ]

This issue also breaks clojurescript in very random ways. On my test project, (require 'cljs.repl) just throws without any hint to the cause.

Comment by Ambrose Bonnaire-Sergeant [ 18/Apr/15 11:02 PM ]

0.2.86 jar omits all AOT files and supports 1.7.0-alpha6.





[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-190] pred doesn't handle much Created: 07/Jan/15  Updated: 07/Jan/15

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

Clojure 1.7.0-alpha4, core.typed 0.2.77



 Description   

<pre>01:37:30 zilti: ambrosebs: Ok so ((pred HandlerComp) component) (component is a record) gives me the ":DataType not suppored in type->pred: Handler" exception at code compilation time...
01:37:56 ambrosebs: yes pred doesn't handle many things right now
01:38:19 zilti: Ah. Ok.
01:38:22 ambrosebs: worth a ticket
01:38:30 ambrosebs: I think datatypes/records can be supported</pre>






[CTYP-189] code that used to type check in 0.2.72 stopped type checking 0.2.77 Created: 06/Jan/15  Updated: 19/Jul/15  Resolved: 11/Mar/15

Status: Closed
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: Completed Votes: 0
Labels: None


 Description   

>> according to @ambrosebs:
19:56 <freakhill> 19:05 <freakhill> do you have an idea of what
causes that bug?
19:56 <freakhill> so i can isolate a failing example?
20:00 *** arohner QUIT Ping timeout: 265 seconds
20:11 <ambrosebs> freakhill: this one I think (t/cf (t/for [x :-
t/AnyInteger, ['(1 2) '(3 4)]] :- (t/Seq
t/AnyInteger) x))
20:21 <freakhill> thanks
20:29 <ambrosebs> nil strikes again
https://twitter.com/ambrosebs/status/552401747084595200
20:30 <freakhill> (t/fn [] :- '{} (into {} '())) crashes too
20:31 <ambrosebs> that makes sense
20:32 <ambrosebs> the issue is anonymous functions that don't have
an explicit :filters (which is impossible to
expression atm)
20:32 <ambrosebs> *express
20:32 <ambrosebs> I use a NoFilter to say "infer this filter and
add to the resulting function type"
20:33 <ambrosebs> but I forgot to handle NoFilter deeper in the
proposition simplification machinery
20:33 <ambrosebs> that assertion catches the sloppiness, a NoFilter
is being returned
20:34 <ambrosebs> I don't know how I don't have a unit test that
fails
20:34 <freakhill> thanks for the deeper insight!
20:35 <ambrosebs> ah probably because the proposition environment
only needs to simplify if there's a complex
expression inside of the fn
20:35 <ambrosebs> I bet I just have values and branches, instead of
`into` which is a polymorphic invocation
20:36 <ambrosebs> eh maybe
>

with: [org.clojure/core.typed "0.2.77"]

nREPL server started on port 58960 on host 127.0.0.1
REPL-y 0.3.0
Clojure 1.7.0-alpha4
    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/for [x :- t/AnyInteger ['(1 2) '(3 4)]] :- (t/Seq t/AnyInteger) x))
Initializing core.typed ...
WARNING: update already refers to: #'clojure.core/update in namespace: clojure.math.combinatorics, being replaced by: #'clojure.math.combinatorics/update
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 4139.835776 msecs"
core.typed initialized.

AssertionError Assert failed: (let [[derived-props derived-atoms] %] (and (every? (some-fn fl/ImpFilter? fl/OrFilter? fl/AndFilter?) derived-props) (every? (some-fn fl/TypeFilter? fl/NotTypeFilter?) derived-atoms)))  clojure.core.typed.update/combine-props (update.clj:57)
user=>

nREPL server started on port 59023 on host 127.0.0.1                        
REPL-y 0.3.0                                                                
Clojure 1.7.0-alpha4                                                        
    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 [] :- '{} (into {} '())))                                
Initializing core.typed ...                                                 
WARNING: update already refers to: #'clojure.core/update in namespace: cloju
re.math.combinatorics, being replaced by: #'clojure.math.combinatorics/updat
e                                                                           
Building core.typed base environments ...                                   
Finished building base environments                                         
"Elapsed time: 4026.279163 msecs"                                           
core.typed initialized.                                                     
                                                                            
AssertionError Assert failed: (let [[derived-props derived-atoms] %] (and (e
very? (some-fn fl/ImpFilter? fl/OrFilter? fl/AndFilter?) derived-props) (eve
ry? (some-fn fl/TypeFilter? fl/NotTypeFilter?) derived-atoms)))  clojure.cor
e.typed.update/combine-props (update.clj:57)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 07/Feb/15 3:12 PM ]

Need to be stricter about where NoFilter is allowed. Maybe should not be allowed inside a FilterSet.

Comment by Ambrose Bonnaire-Sergeant [ 11/Mar/15 9:17 PM ]

Fixed in 0.2.84 https://github.com/clojure/core.typed/commit/c6dff02d6d9bb86c5221a19419a0ee6fe121a2d2

Comment by Johan Gall [ 11/Mar/15 10:52 PM ]

thanks a lot!





[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-187] Add a defn- macro for private functions Created: 04/Jan/15  Updated: 05/Jan/15

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

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


 Description   

It would be very useful to have a "defn-" macro in core.typed so that private functions can be more easily annotated.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 04/Jan/15 9:24 PM ]

I would much rather minimise the number of wrapper macros. I would suggest ^:private metadata w/ the "defn" macro instead.

Comment by James Reeves [ 05/Jan/15 4:36 AM ]

Usually I'd agree wholeheartedly with this sentiment. However, in many Clojure projects the majority of functions are tagged private, and I'd suggest particularly so in projects written around core.typed. Adding annotations to anonymous functions can be a little verbose to do inline, and I've found myself pulling out anonymous functions into private named functions more than I would otherwise.

Given how common private functions are, using ^:private metadata quickly becomes a verbose and tedious bit of boilerplate. While this may be a historical artifact, Clojure itself makes an exception for private functions with "defn-". It would be nice if this same exception was present in core.typed.





[CTYP-186] Type check restore-right Created: 04/Jan/15  Updated: 04/Jan/15  Resolved: 04/Jan/15

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

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


 Description   

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






[CTYP-185] base-env load ordering yields confusing error Created: 04/Jan/15  Updated: 04/Jan/15  Resolved: 04/Jan/15

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:25 PM <dblarons> ambrosebs: On 0.2.73 and later, (t/cf (t/for [x :- t/Num, [1 2 3 4]] :- t/Num x)) gives a Type Error. "Cannot resolve type: IFn"
10:25 PM <dblarons> I checked 0.2.72 and it checks as (clojure.lang.LazySeq Number) like I would have expected it to.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 04/Jan/15 2:16 PM ]

Fixed in 0.2.77 https://github.com/clojure/core.typed/commit/62a0c5d938a57f2f86a82210d3edfb2c5d10d610





[CTYP-184] File-encoding problem while checking NS Created: 23/Dec/14  Updated: 30/Dec/14  Resolved: 30/Dec/14

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

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

Linux Mint Petra



 Description   

When I tried to check a namespace in a directory with a non-ascii character (/home/ctford/Código/traversy), I got the following exception:

traversy.lens=> (clojure.core.typed/check-ns)
Start collecting traversy.lens

FileNotFoundException /home/ctford/Código/traversy/src/traversy/lens.clj (No existe el archivo o el directorio) java.io.FileInputStream.open (FileInputStream.java:-2)
traversy.lens=> (pst)
FileNotFoundException /home/ctford/Código/traversy/src/traversy/lens.clj (No existe el archivo o el directorio)
java.io.FileInputStream.open (FileInputStream.java:-2)
java.io.FileInputStream.<init> (FileInputStream.java:146)
clojure.java.io/fn--8642 (io.clj:242)
clojure.java.io/fn-8577/G8542-8584 (io.clj:73)
clojure.java.io/fn--8612 (io.clj:169)
clojure.java.io/fn-8551/G8546-8558 (io.clj:73)
clojure.java.io/reader (io.clj:106)
clojure.tools.namespace.file/read-file-ns-decl (file.clj:22)
clojure.core.typed.ns-deps-utils/ns-form-for-file (ns_deps_utils.clj:19)
clojure.core.typed.ns-deps-utils/ns-form-for-ns (ns_deps_utils.clj:29)
clojure.core.typed.ns-deps-utils/deps-for-ns (ns_deps_utils.clj:46)
clojure.core.typed.collect-utils/collect-ns* (collect_utils.clj:74)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 23/Dec/14 12:28 PM ]

Some notes:

Comment by Chris Ford [ 23/Dec/14 12:29 PM ]

I can confirm that calling read-file-ns-decl with the path in question directly works, so I assume the problem is in how the filename is calculated:

(ns file-encoding.core
(:require [clojure.tools.namespace.file :as file]))

(file/read-file-ns-decl
"/home/ctford/Código/file-encoding/src/file_encoding/core.clj")

(ns file-encoding.core (:require [clojure.tools.namespace.file :as file]))

Comment by Ambrose Bonnaire-Sergeant [ 23/Dec/14 12:46 PM ]

What does this output?

(require '[clojure.java.io :as io]
         '[clojure.core.typed.coerce-utils :as coerce]
         '[clojure.tools.namespace.file :as file])

(prn (coerce/ns->file 'file-encoding.core))

(prn (io/resource (coerce/ns->file 'file-encoding.core)))

(prn (file/read-file-ns-decl (io/resource (coerce/ns->file 'file-encoding.core))))
Comment by Chris Ford [ 23/Dec/14 12:55 PM ]

I get an error because I don't have a specified "impl".

Comment by Chris Ford [ 23/Dec/14 1:14 PM ]

I hardcoded .clj to avoid the impl macro problem.

After the first call I get:
"file_encoding/core.clj"

But after the second I get:
#<URL file:/home/ctford/C%c3%b3digo/file-encoding/src/file_encoding/core.clj>

That looks like the resulting URL has problems - it's encoded the accented o with two characters.

The third call throws the FileNotFoundException.

Comment by Chris Ford [ 23/Dec/14 3:08 PM ]

Looks like the problem is in the URL coding and decoding. This works:

(-> "file_encoding/core.clj" resource str java.net.URLDecoder/decode file/read-file-ns-decl)

I've hacked a quick fix for the issue. I'll test it and let you know.

https://github.com/ctford/core.typed/commit/4e68628b0e0a0c60a8e1ee60fadbb524684810d7

Comment by Chris Ford [ 23/Dec/14 4:28 PM ]

I had to push a second commit addressing other uses of io/reader - this probably should be centralised if a fix is shown to work.

When I tested the fix, I ran across two problems that are probably not related to the fix itself. Firstly, something odd happened that seemed to be related to ClojureScript:

ctford@wasumo ~/Código/traversy $ lein typed check
Initializing core.typed ...
Found ClojureScript, loading ...
nil
Found errors
Subprocess failed

And then once I'd disabled .cljs by attacking the when clause that checks for analyzer.clj in module-check/src/main/clojure/clojure/core/typed/init.clj:

Start collecting traversy.lens
Finished collecting traversy.lens
Collected 1 namespaces in 1109.318591 msecs
Not checking clojure.core.typed (does not depend on clojure.core.typed)
Start checking traversy.lens


IllegalArgumentException No value supplied for key: true  clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)
traversy.lens=> (pst)
IllegalArgumentException No value supplied for key: true
	clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)
	clojure.core.typed.type-rep/-hset (type_rep.clj:598)
	clojure.core.typed.promote-demote/eval21945/fn--21946/f--21759--auto----21947 (promote_demote.clj:221)
	clojure.core.typed.promote-demote/eval21945/fn--21946 (promote_demote.clj:218)
	clojure.lang.MultiFn.invoke (MultiFn.java:231)
	clojure.core/map/fn--4211 (core.clj:2492)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:60)
	clojure.lang.Cons.next (Cons.java:39)
	clojure.lang.RT.boundedLength (RT.java:1654)
	clojure.core/apply (core.clj:617)
	clojure.core.typed.promote-demote/eval22415/fn--22416/f--21759--auto----22417 (promote_demote.clj:305)
nil

Could these errors be related to other things in HEAD? Or have I broken stuff I didn't understand?

Comment by Chris Ford [ 24/Dec/14 6:33 AM ]

Avoiding file URLs altogether might be a more robust fix. This works:

(defn ^java.io.InputStream stream-resource
  "Returns an InputStream for a named resource. Use the context class loader
   if no loader is specified.

   Based on clojure.java.io/resource"
  ([n] (stream-resource n (.getContextClassLoader (Thread/currentThread))))
  ([n ^ClassLoader loader] (.getResourceAsStream loader n)))

(-> "file_encoding/core.clj" stream-resource io/reader file/read-file-ns-decl)
Comment by Chris Ford [ 24/Dec/14 10:26 AM ]

This appears to have been fixed in Clojure 1.6 - http://dev.clojure.org/jira/browse/CLJ-1177





[CTYP-183] No such var: ana/ns->relpath exception on any attempt Created: 12/Dec/14  Updated: 30/Dec/14  Resolved: 30/Dec/14

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

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


 Description   

I've tried the last commit version df2c0e1904729d5f5ec07d88e87783854741c6a4

Any attempt to use it leads to the folowwing exception:

java.lang.RuntimeException: No such var: ana/ns->relpath, compiling:(cljs/jvm/tools/analyzer.clj:39:13)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 30/Dec/14 5:54 PM ]

Duplicate CTYP-176





[CTYP-182] macros which define functions containing named anonymous functions crash Created: 09/Dec/14  Updated: 02/Jan/15

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

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


 Description   
(defmacro deft [name args & body]
  `(defn ~name []
     (fn build [] ~@body)))

(ann foo (IFn [Any nil -> Any]))
(deft foo [x] 2)

throws an exception complaining about a missing lexical environment, which can be fixed by unquote-splicing the quoted name: ~'build instead of build.

ERROR in (typecheck) (lex_env.clj:12)
expected: (check-ns (quote tesser.core))
  actual: java.lang.AssertionError: Pre-condition failure: A lexical environment l, props is a list of known propositions
Assert failed: (lex-env? l)
 at clojure.core.typed.lex_env$__GT_PropEnv$chk_PropEnv__11227$fn__11229.invoke (lex_env.clj:12)
    clojure.core.typed.lex_env$__GT_PropEnv$chk_PropEnv__11227.invoke (lex_env.clj:12)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:626)
    clojure.core$partial$fn__4228.doInvoke (core.clj:2468)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.core.contracts.constraints$apply_contract$fn__1927.doInvoke (constraints.clj:174)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.invoke (RestFn.java:436)
    clojure.core$update_in.doInvoke (core.clj:5698)
    clojure.lang.RestFn.invoke (RestFn.java:445)
    clojure.lang.AFn.applyToHelper (AFn.java:160)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.core$apply.invoke (core.clj:626)
    clojure.core.contracts.constraints$apply_contract$fn__1927.doInvoke (constraints.clj:174)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.invoke (RestFn.java:436)
    clojure.core.typed.lex_env$merge_locals.invoke (lex_env.clj:35)
    clojure.core.typed.check.fn_methods$check_fn_methods.doInvoke (fn_methods.clj:48)
    clojure.lang.RestFn.invoke (RestFn.java:464)
    clojure.core.typed.check.fn$check_fn.invoke (fn.clj:25)
    clojure.core.typed.check$check _COLON_fn22307$fn__22317.invoke (check.clj:1282)
    clojure.core.typed.check$check _COLON_fn22307.doInvoke (check.clj:1255)
    clojure.lang.RestFn.invoke (RestFn.java:423)
    clojure.lang.MultiFn.invoke (MultiFn.java:231)
    clojure.core.typed.check$check _COLON_with_meta22482.doInvoke (check.clj:1589)
    clojure.lang.RestFn.invoke (RestFn.java:423)
    clojure.lang.MultiFn.invoke (MultiFn.java:231)
    clojure.core.typed.check.do$check_do$fn__21306$fn__21309.invoke (do.clj:40)
    clojure.core.typed.check.do$check_do$fn__21306.invoke (do.clj:32)
    clojure.lang.ArrayChunk.reduce (ArrayChunk.java:58)
    clojure.core.protocols/fn (protocols.clj:98)
    clojure.core.protocols$fn__6057$G__6052__6066.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invoke (protocols.clj:31)
    clojure.core.protocols/fn (protocols.clj:54)
    clojure.core.protocols$fn__6031$G__6026__6044.invoke (protocols.clj:13)
    clojure.core$reduce.invoke (core.clj:6289)
    clojure.core.typed.check.do$check_do.invoke (do.clj:69)
    clojure.core.typed.check$check _COLON_do22363.doInvoke (check.clj:1330)
    clojure.lang.RestFn.invoke (RestFn.java:423)
    clojure.lang.MultiFn.invoke (MultiFn.java:231)
    clojure.core.typed.check.fn_method_one$check_fn_method1$fn__21492.invoke (fn_method_one.clj:179)
    clojure.core.typed.check.fn_method_one$check_fn_method1.doInvoke (fn_method_one.clj:169)
    clojure.lang.RestFn.invoke (RestFn.java:464)
    clojure.core.typed.check.fn_method$check_fn_method.doInvoke (fn_method.clj:26)
    clojure.lang.RestFn.invoke (RestFn.java:464)
    clojure.core.typed.check.fn_methods$check_fn_methods$fn__21544$fn__21551.invoke (fn_methods.clj:62)
    clojure.core$mapv$fn__6311.invoke (core.clj:6353)
    clojure.lang.ArrayChunk.reduce (ArrayChunk.java:58)
    clojure.core.protocols/fn (protocols.clj:98)
    clojure.core.protocols$fn__6057$G__6052__6066.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invoke (protocols.clj:31)
    clojure.core.protocols/fn (protocols.clj:60)
    clojure.core.protocols$fn__6031$G__6026__6044.invoke (protocols.clj:13)
    clojure.core$reduce.invoke (core.clj:6289)
    clojure.core$mapv.invoke (core.clj:6353)
    clojure.core.typed.check.fn_methods$check_fn_methods$fn__21544.invoke (fn_methods.clj:60)
    clojure.core.typed.check.fn_methods$check_fn_methods.doInvoke (fn_methods.clj:45)
    clojure.lang.RestFn.invoke (RestFn.java:464)
    clojure.core.typed.check.fn$check_fn.invoke (fn.clj:25)
    clojure.core.typed.check$check _COLON_fn22307$fn__22317.invoke (check.clj:1282)
    clojure.core.typed.check$check _COLON_fn22307.doInvoke (check.clj:1255)
    clojure.lang.RestFn.invoke (RestFn.java:423)
    clojure.lang.MultiFn.invoke (MultiFn.java:231)
    clojure.core.typed.check.def$check_normal_def$fn__11342.invoke (def.clj:31)
    clojure.core.typed.check.def$check_normal_def.doInvoke (def.clj:29)
    clojure.lang.RestFn.invoke (RestFn.java:442)
    clojure.core.typed.check$check _COLON_def22496.doInvoke (check.clj:1624)
    clojure.lang.RestFn.invoke (RestFn.java:423)
    clojure.lang.MultiFn.invoke (MultiFn.java:231)
    clojure.core.typed.check$check_expr.doInvoke (check.clj:148)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    clojure.core.typed.check$check_asts$iter__21742__21746$fn__21747$fn__21748.invoke (check.clj:117)
    clojure.core.typed.check$check_asts$iter__21742__21746$fn__21747.invoke (check.clj:116)
    clojure.lang.LazySeq.sval (LazySeq.java:40)
    clojure.lang.LazySeq.seq (LazySeq.java:49)
    clojure.lang.RT.seq (RT.java:484)
    clojure.core$seq.invoke (core.clj:133)
    clojure.core$dorun.invoke (core.clj:2855)
    clojure.core$doall.invoke (core.clj:2871)
    clojure.core.typed.check$check_asts.invoke (check.clj:116)
    clojure.core.typed.check.utils$check_ns_and_deps_STAR_.invoke (utils.clj:472)
    clojure.core.typed.check$check_ns_and_deps.invoke (check.clj:128)
    clojure.core.typed.check_ns_common$check_ns_info$fn__25014$fn__25015.invoke (check_ns_common.clj:81)
    clojure.core.typed.check_ns_common$check_ns_info$fn__25014.invoke (check_ns_common.clj:57)
    clojure.lang.AFn.applyToHelper (AFn.java:152)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invoke (core.clj:624)
    clojure.core$with_bindings_STAR_.doInvoke (core.clj:1862)
    clojure.lang.RestFn.invoke (RestFn.java:425)
    clojure.core.typed.check_ns_common$check_ns_info.doInvoke (check_ns_common.clj:42)
    clojure.lang.RestFn.invoke (RestFn.java:425)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.core$apply.invoke (core.clj:628)
    clojure.core.typed.check_ns_common$check_ns.doInvoke (check_ns_common.clj:111)
    clojure.lang.RestFn.invoke (RestFn.java:425)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.core$apply.invoke (core.clj:628)
    clojure.core.typed.check_ns_clj$check_ns.doInvoke (check_ns_clj.clj:23)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.core$apply.invoke (core.clj:626)
    clojure.core.typed$check_ns.doInvoke (typed.clj:2225)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.core$apply.invoke (core.clj:624)
    tesser.core_test/fn (core_test.clj:19)
    clojure.test$test_var$fn__7187.invoke (test.clj:704)
    clojure.test$test_var.invoke (test.clj:704)
    clojure.test$test_vars$fn__7209$fn__7214.invoke (test.clj:722)
    clojure.test$default_fixture.invoke (test.clj:674)
    clojure.test$test_vars$fn__7209.invoke (test.clj:722)
    clojure.test$default_fixture.invoke (test.clj:674)
    clojure.test$test_vars.invoke (test.clj:718)
    clojure.test$test_all_vars.invoke (test.clj:728)
    clojure.test$test_ns.invoke (test.clj:747)
    clojure.core$map$fn__4245.invoke (core.clj:2559)
    clojure.lang.LazySeq.sval (LazySeq.java:40)
    clojure.lang.LazySeq.seq (LazySeq.java:49)
    clojure.lang.Cons.next (Cons.java:39)
    clojure.lang.RT.boundedLength (RT.java:1654)
    clojure.lang.RestFn.applyTo (RestFn.java:130)
    clojure.core$apply.invoke (core.clj:626)
    clojure.test$run_tests.doInvoke (test.clj:762)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    com.aphyr.prism$autotest_BANG_$fn__228.invoke (prism.clj:130)
    com.aphyr.prism$namespace_changed$fn__209.invoke (prism.clj:90)
    com.aphyr.prism$namespace_changed.invoke (prism.clj:88)
    com.aphyr.prism$watch_BANG_$fn__214$fn__215.invoke (prism.clj:111)
    clojure.core$binding_conveyor_fn$fn__4145.invoke (core.clj:1910)
    clojure.lang.AFn.call (AFn.java:18)
    java.util.concurrent.FutureTask.run (FutureTask.java:262)
    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
    java.lang.Thread.run (Thread.java:745)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 02/Jan/15 6:48 PM ]

This is because (fn user/build ..) is valid to tools.analyzer even though it doesn't mean much.





[CTYP-181] (float)'s type is mistakenly (Any -> Float) Created: 09/Dec/14  Updated: 18/May/15  Resolved: 18/May/15

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

Type: Defect Priority: Minor
Reporter: Kyle Kingsbury Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None


 Description   
user=> (cf float)
[Any -> java.lang.Float]
user=> (float "5")

ClassCastException java.lang.String cannot be cast to java.lang.Number  clojure.lang.RT.floatCast (RT.java:1186)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 18/May/15 5:03 AM ]

Fixed in 0.2.89 https://github.com/clojure/core.typed/commit/f2e027c1f3537195aa1f484c3f599d23945a86aa





[CTYP-180] support (locking) expressions Created: 09/Dec/14  Updated: 19/Jul/15  Resolved: 09/Dec/14

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

Type: Defect Priority: Minor
Reporter: Kyle Kingsbury Assignee: Kyle Kingsbury
Resolution: Completed Votes: 0
Labels: None

Attachments: File locking.diff    
Patch: Code and Test
Waiting On: Ambrose Bonnaire-Sergeant

 Description   

(locking x) won't typecheck because monitor-enter and monitor-exit aren't supported by the checker. This patch adds tests and support for those expressions.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Dec/14 4:15 PM ]

Merged.





[CTYP-179] reduced? has type [Object -> Boolean], not [Any -> Boolean] Created: 09/Dec/14  Updated: 20/Jul/15  Resolved: 09/Dec/14

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

Type: Defect Priority: Minor
Reporter: Kyle Kingsbury Assignee: Kyle Kingsbury
Resolution: Completed Votes: 0
Labels: None

Attachments: File reduced.diff    
Patch: Code and Test
Waiting On: Ambrose Bonnaire-Sergeant

 Description   

Functions like (fn [x] (reduced? x)) won't typecheck because clojure.RT.isReduced expects Objects; however, Clojure's autoboxing semantics mean this code is correct. The attached patch updates the method overrides so the signature is [Any -> Boolean].



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 09/Dec/14 4:15 PM ]

Merged.





[CTYP-178] Dissimilar lengths of HVecs in a union doesn't type-check Created: 02/Dec/14  Updated: 02/Dec/14

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

Type: Defect Priority: Minor
Reporter: Edward Cho 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.match "0.2.1"]



 Description   

Setting up a simple union type for nats with a vector encoding, where the first element is the tag (:zero or :succ). The :zero constructor is nullary, but the :succ constructor recurses. The type checker doesn't seem to correctly handle union types consisting of HVecs of different lengths

The namespace:

(ns arith.core
(:require [clojure.core.typed :refer [ann defalias Rec U Val Int print-env]]
[clojure.core.match :refer [match]]))

(defalias Expr
(Rec [Expr]
(U '[(Val :zero)]
'[(Val :succ) Expr])))

(ann evaluate [Expr -> Int])
;; (defn evaluate [e]
;; (match e
;; [:zero] 0
;; [:succ t1] (inc (evaluate t1))))
;; => macroexpands to =>
(def evaluate
(fn* ([e]
(try
(if (let* [and__3973__auto__ (clojure.core/vector? e)]
(if and_3973auto_
(clojure.core/== (clojure.core/count e) 1)
and_3973auto_))
(try
(let* [e_0__45691 (clojure.core/nth e 0)]
(if (clojure.core/= e_0__45691 :zero)
0
(if :else (throw clojure.core.match/backtrack) nil)))
(catch Exception e_3853auto_
(if (clojure.core/identical? e_3853auto_ clojure.core.match/backtrack)
(do (throw clojure.core.match/backtrack))
(throw e_3853auto_))))
(if :else (throw clojure.core.match/backtrack) nil))
(catch Exception e_3853auto_
(if (clojure.core/identical? e_3853auto_ clojure.core.match/backtrack)
(do
(try
(if (let* [and__3973__auto__ (clojure.core/vector? e)]
(if and_3973auto_
(clojure.core/== (clojure.core/count e) 2)
and_3973auto_))
(try
(let* [e_0__45692 (clojure.core/nth e 0)]
(if (clojure.core/= e_0__45692 :succ) ;; type checker points here
(let* [_ (print-env "here")
t1 (clojure.core/nth e 1)]
(inc (evaluate t1)))
(if :else (throw clojure.core.match/backtrack) nil)))
(catch Exception e_3853auto_
(if (clojure.core/identical? e_3853auto_ clojure.core.match/backtrack)
(do
(throw clojure.core.match/backtrack))
(throw e_3853auto_))))
(if :else (throw clojure.core.match/backtrack) nil))
(catch Exception e_3853auto_
(if (clojure.core/identical? e_3853auto_ clojure.core.match/backtrack)
(do (throw (new java.lang.IllegalArgumentException (clojure.core/str "No matching clause: " e))))
(throw e_3853auto_)))))
(throw e_3853auto_)))))))

(comment
(clojure.core.typed/check-ns)
(evaluate [:zero])
(evaluate [:succ [:zero]])
(evaluate [:succ [:succ [:zero]]]))

The inserted print-env yields:

{:env

Unknown macro: {e_0__45692__#0 (Val }
, :props ((is (Val :succ) e_0_45692#0) (when (! (U nil false) e_045692#0) (is (clojure.core.typed/I (Seqable clojure.core.typed/Any) (clojure.core.typed/CountRange 1)) e_#0)))}

And the full stack trace:

Show: Clojure Java REPL Tooling Duplicates All (0 frames hidden)

2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling:
/Users/zerokarmaleft/Projects/tapl/tapl-clojure/arith/src/arith/core.clj:3:50

Compiler.java: 7142 clojure.lang.Compiler/load
REPL: 1 user/eval49200
Compiler.java: 6703 clojure.lang.Compiler/eval
Compiler.java: 6666 clojure.lang.Compiler/eval
core.clj: 2927 clojure.core/eval
main.clj: 239 clojure.main/repl/read-eval-print/fn
main.clj: 239 clojure.main/repl/read-eval-print
main.clj: 257 clojure.main/repl/fn
main.clj: 257 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 67 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 624 clojure.core/apply
core.clj: 1862 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 51 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 183 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 152 clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1142 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 617 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 744 java.lang.Thread/run

1. Caused by clojure.lang.ExceptionInfo
Type Checker: Found 1 error
{:type-error :top-level-error,
:errors
(#<ExceptionInfo clojure.lang.ExceptionInfo: Internal Error (arith/core.clj:43:27) Cannot get index 1 from type (clojure.core.typed/HVec [(clojure.core.typed/Val :zero)]) {:type-error :clojure.core.typed.errors/internal-error, :env {:no-recur true, :loop-locals 1, :locals {e {:form e, :name e_#0, :variadic? false, :op :binding, :arg-id 0, :local :arg}, e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto__#1, :local :catch, :tag Exception}, e_045692 {:op :binding, :name e_045692_#0, :init {:raw-forms ((clojure.core/nth e 0)), :children [:target :args], :args [{:env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e_3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :children [], :assignable? false, :form e, :name e, :variadic? false, :op :local, :arg-id 0, :local :arg} {:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :number, :literal? true, :val 0, :form 0}], :method nth, :op :host-call, :form (. clojure.lang.RT (clojure.core/nth e 0)), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :target {:form clojure.lang.RT, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :maybe-class, :class clojure.lang.RT}}, :form e_0_45692, :local :let, :children [:init]}, _ {:op :binding, :name ___#0, :init {:children [:fn :args], :meta {:end-column 56, :end-line 44, :column 38, :line 44, :file "arith/core.clj"}, :op :invoke, :form (print-env "here"), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e_0_45692 {:op :binding, :name e_0_45692, :init {:raw-forms ((clojure.core/nth e 0)), :children [:target :args], :args [{:env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e_3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :children [], :assignable? false, :form e, :name e, :variadic? false, :op :local, :arg-id 0, :local :arg} {:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :number, :literal? true, :val 0, :form 0}], :method nth, :op :host-call, :form (. clojure.lang.RT (clojure.core/nth e 0)), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :target {:form clojure.lang.RT, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :maybe-class, :class clojure.lang.RT}}, :form e_0_45692, :local :let, :children [:init]}, e_3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :fn {:form print-env, :env {:in-try true, :no-recur true, :once false, :context :ctx.invoke/target, :locals {e_045692 {:op :binding, :name e_0_45692, :init {:raw-forms ((clojure.core/nth e 0)), :children [:target :args], :args [{:env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e_3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :children [], :assignable? false, :form e, :name e, :variadic? false, :op :local, :arg-id 0, :local :arg} {:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :number, :literal? true, :val 0, :form 0}], :method nth, :op :host-call, :form (. clojure.lang.RT (clojure.core/nth e 0)), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :target {:form clojure.lang.RT, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :maybe-class, :class clojure.lang.RT}}, :form e_0_45692, :local :let, :children [:init]}, e_3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :var, :assignable? false, :var #'clojure.core.typed/print-env}, :args [{:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx.invoke/param, :locals {e_045692 {:op :binding, :name e_0_45692, :init {:raw-forms ((clojure.core/nth e 0)), :children [:target :args], :args [{:env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e_3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :children [], :assignable? false, :form e, :name e, :variadic? false, :op :local, :arg-id 0, :local :arg} {:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :number, :literal? true, :val 0, :form 0}], :method nth, :op :host-call, :form (. clojure.lang.RT (clojure.core/nth e 0)), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :target {:form clojure.lang.RT, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e3853auto_ {:op :binding, :form e_3853auto, :name e3853auto, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :maybe-class, :class clojure.lang.RT}}, :form e_0_45692, :local :let, :children [:init]}, e_3853auto_ {:op :binding, :form e_3853auto, :name e3853auto_, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :string, :literal? true, :val "here", :form "here"}]}, :form _, :local :let, :children [:init]}}, :ns arith.core, :loop-id loop_49240, :file "arith/core.clj", :end-column 61, :column 39, :in-try true, :line 45, :once false, :end-line 45, :context :ctx/expr, :internal-name "evaluate$fn__49242$t1"}}>)}

core.clj: 4403 clojure.core/ex-info
errors.clj: 232 clojure.core.typed.errors/print-errors!
check_ns_common.clj: 114 clojure.core.typed.check-ns-common/check-ns/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 624 clojure.core/apply
core.clj: 1862 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
check_ns_common.clj: 112 clojure.core.typed.check-ns-common/check-ns
RestFn.java: 425 clojure.lang.RestFn/invoke
AFn.java: 156 clojure.lang.AFn/applyToHelper
RestFn.java: 132 clojure.lang.RestFn/applyTo
core.clj: 628 clojure.core/apply
check_ns_clj.clj: 23 clojure.core.typed.check-ns-clj/check-ns
RestFn.java: 410 clojure.lang.RestFn/invoke
AFn.java: 154 clojure.lang.AFn/applyToHelper
RestFn.java: 132 clojure.lang.RestFn/applyTo
core.clj: 626 clojure.core/apply
typed.clj: 2225 clojure.core.typed/check-ns
RestFn.java: 410 clojure.lang.RestFn/invoke
typed.clj: 2222 clojure.core.typed/check-ns
core.clj: 61 arith.core/eval49212
Compiler.java: 6703 clojure.lang.Compiler/eval
Compiler.java: 7130 clojure.lang.Compiler/load
REPL: 1 user/eval49200
Compiler.java: 6703 clojure.lang.Compiler/eval
Compiler.java: 6666 clojure.lang.Compiler/eval
core.clj: 2927 clojure.core/eval
main.clj: 239 clojure.main/repl/read-eval-print/fn
main.clj: 239 clojure.main/repl/read-eval-print
main.clj: 257 clojure.main/repl/fn
main.clj: 257 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 67 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 624 clojure.core/apply
core.clj: 1862 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 51 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 183 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 152 clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1142 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 617 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 744 java.lang.Thread/run



 Comments   
Comment by Edward Cho [ 02/Dec/14 2:49 PM ]

Sorry, forgot JIRA eats formatting.

(ns arith.core
  (:require [clojure.core.typed :refer [ann defalias Rec U Val Int print-env]]
            [clojure.core.match :refer [match]]))

(defalias Expr
  (Rec [Expr]
    (U '[(Val :zero)]
       '[(Val :succ) Expr])))

(ann evaluate [Expr -> Int])
;; (defn evaluate [e]
;;   (match e
;;     [:zero]    0
;;     [:succ t1] (inc (evaluate t1))))
;; => macroexpands to =>
(def evaluate
  (fn* ([e]
          (try
            (if (let* [and__3973__auto__ (clojure.core/vector? e)]
                  (if and__3973__auto__
                    (clojure.core/== (clojure.core/count e) 1)
                    and__3973__auto__))
              (try
                (let* [e_0__45691 (clojure.core/nth e 0)]
                  (if (clojure.core/= e_0__45691 :zero)
                    0
                    (if :else (throw clojure.core.match/backtrack) nil)))
                (catch Exception e__3853__auto__
                  (if (clojure.core/identical? e__3853__auto__ clojure.core.match/backtrack)
                    (do (throw clojure.core.match/backtrack))
                    (throw e__3853__auto__))))
              (if :else (throw clojure.core.match/backtrack) nil))
            (catch Exception e__3853__auto__
              (if (clojure.core/identical? e__3853__auto__ clojure.core.match/backtrack)
                (do
                  (try
                    (if (let* [and__3973__auto__ (clojure.core/vector? e)]
                          (if and__3973__auto__
                            (clojure.core/== (clojure.core/count e) 2)
                            and__3973__auto__))
                      (try
                        (let* [e_0__45692 (clojure.core/nth e 0)]
                          (if (clojure.core/= e_0__45692 :succ)
                            (let* [_ (print-env "here")
                                   t1 (clojure.core/nth e 1)]
                                  (inc (evaluate t1)))
                            (if :else (throw clojure.core.match/backtrack) nil)))
                        (catch Exception e__3853__auto__
                          (if (clojure.core/identical? e__3853__auto__ clojure.core.match/backtrack)
                            (do
                              (throw clojure.core.match/backtrack))
                            (throw e__3853__auto__))))
                      (if :else (throw clojure.core.match/backtrack) nil))
                    (catch Exception e__3853__auto__
                      (if (clojure.core/identical? e__3853__auto__ clojure.core.match/backtrack)
                        (do (throw (new java.lang.IllegalArgumentException (clojure.core/str "No matching clause: " e))))
                        (throw e__3853__auto__)))))
                (throw e__3853__auto__)))))))

(comment
  (clojure.core.typed/check-ns)
  (evaluate [:zero])
  (evaluate [:succ [:zero]])
  (evaluate [:succ [:succ [:zero]]]))
{:env {e_0__45692__#0 (Val :succ), 
       e__3853__auto____#1 Exception, 
       e__#0 Expr}, 
 :props ((is (Val :succ) e_0__45692__#0) 
         (when (! (U nil false) e_0__45692__#0) 
               (is (clojure.core.typed/I (Seqable clojure.core.typed/Any) (clojure.core.typed/CountRange 1)) e__#0)))}
(#<ExceptionInfo clojure.lang.ExceptionInfo: Internal Error (arith/core.clj:43:27) Cannot get index 1 from type (clojure.core.typed/HVec [(clojure.core.typed/Val :zero)]) {:type-error :clojure.core.typed.errors/internal-error, :env {:no-recur true, :loop-locals 1, :locals {e {:form e, :name e__#0, :variadic? false, :op :binding, :arg-id 0, :local :arg}, e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto____#1, :local :catch, :tag Exception}, e_0__45692 {:op :binding, :name e_0__45692__#0, :init {:raw-forms ((clojure.core/nth e 0)), :children [:target :args], :args [{:env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :children [], :assignable? false, :form e, :name e, :variadic? false, :op :local, :arg-id 0, :local :arg} {:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :number, :literal? true, :val 0, :form 0}], :method nth, :op :host-call, :form (. clojure.lang.RT (clojure.core/nth e 0)), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :target {:form clojure.lang.RT, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :maybe-class, :class clojure.lang.RT}}, :form e_0__45692, :local :let, :children [:init]}, _ {:op :binding, :name ___#0, :init {:children [:fn :args], :meta {:end-column 56, :end-line 44, :column 38, :line 44, :file "arith/core.clj"}, :op :invoke, :form (print-env "here"), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e_0__45692 {:op :binding, :name e_0__45692, :init {:raw-forms ((clojure.core/nth e 0)), :children [:target :args], :args [{:env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :children [], :assignable? false, :form e, :name e, :variadic? false, :op :local, :arg-id 0, :local :arg} {:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :number, :literal? true, :val 0, :form 0}], :method nth, :op :host-call, :form (. clojure.lang.RT (clojure.core/nth e 0)), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :target {:form clojure.lang.RT, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :maybe-class, :class clojure.lang.RT}}, :form e_0__45692, :local :let, :children [:init]}, e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :fn {:form print-env, :env {:in-try true, :no-recur true, :once false, :context :ctx.invoke/target, :locals {e_0__45692 {:op :binding, :name e_0__45692, :init {:raw-forms ((clojure.core/nth e 0)), :children [:target :args], :args [{:env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :children [], :assignable? false, :form e, :name e, :variadic? false, :op :local, :arg-id 0, :local :arg} {:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :number, :literal? true, :val 0, :form 0}], :method nth, :op :host-call, :form (. clojure.lang.RT (clojure.core/nth e 0)), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :target {:form clojure.lang.RT, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :maybe-class, :class clojure.lang.RT}}, :form e_0__45692, :local :let, :children [:init]}, e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :var, :assignable? false, :var #'clojure.core.typed/print-env}, :args [{:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx.invoke/param, :locals {e_0__45692 {:op :binding, :name e_0__45692, :init {:raw-forms ((clojure.core/nth e 0)), :children [:target :args], :args [{:env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :children [], :assignable? false, :form e, :name e, :variadic? false, :op :local, :arg-id 0, :local :arg} {:op :const, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :number, :literal? true, :val 0, :form 0}], :method nth, :op :host-call, :form (. clojure.lang.RT (clojure.core/nth e 0)), :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :target {:form clojure.lang.RT, :env {:in-try true, :no-recur true, :once false, :context :ctx/expr, :locals {e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :op :maybe-class, :class clojure.lang.RT}}, :form e_0__45692, :local :let, :children [:init]}, e__3853__auto__ {:op :binding, :form e__3853__auto__, :name e__3853__auto__, :local :catch, :tag Exception}, e {:form e, :name e, :variadic? false, :op :binding, :arg-id 0, :local :arg}}, :ns arith.core, :loop-id loop_49240, :loop-locals 1}, :type :string, :literal? true, :val "here", :form "here"}]}, :form _, :local :let, :children [:init]}}, :ns arith.core, :loop-id loop_49240, :file "arith/core.clj", :end-column 61, :column 39, :in-try true, :line 45, :once false, :end-line 45, :context :ctx/expr, :internal-name "evaluate$fn__49242$t1"}}>)}




[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-175] Initializing core.typed ... fails with IllegalArgumentException in CounterClockwise REPL Created: 02/Oct/14  Updated: 02/Oct/14  Resolved: 02/Oct/14

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

Type: Defect Priority: Major
Reporter: Rene Semmelrath Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug
Environment:

core.typed 0.2.70
Eclipse with ccw 0.2.68



 Description   

when I write (cf 1) in the REPL

Initializing core.typed ... fails
and writes:

IllegalArgumentException No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil clojure.core/-cache-protocol-fn (core_deftype.clj:544)

and of course does not work afterwards.

core.typed version 0.2.68 works just fine !!



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 02/Oct/14 9:13 PM ]

Fixed in 0.2.71 https://github.com/clojure/core.typed/commit/ac9562ed849be9441759ad02fffb356f5eef2450





[CTYP-174] More fixes for closed source projects (datomic) Created: 15/Sep/14  Updated: 25/May/15  Resolved: 18/May/15

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

Type: Defect Priority: Major
Reporter: Allen Rohner Assignee: Allen Rohner
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0001-More-fixes-for-nses-with-no-source.patch     File ctyp-174-2.diff    

 Description   

CTYP-166 was incomplete. The attached patch gets farther through checking. I haven't gotten an :ok yet w/ my datomic project, so I don't know if this is complete either

The main change is that the line about "checked N lines" now returns 0 for namespaces where we can't find the source.



 Comments   
Comment by Allen Rohner [ 03/Feb/15 4:05 PM ]

I've successfully gotten ':ok' using this patch. Can it get included?

Comment by Ambrose Bonnaire-Sergeant [ 07/Feb/15 2:47 PM ]

Patch doesn't seem to apply

[abonnair@catbert datomic]$ git am --keep-cr -s --ignore-whitespace < 0001-More-fixes-for-nses-with-no-source.patch 
Applying: More fixes for nses with no source
error: patch failed: module-check/src/main/clojure/clojure/core/typed/check_ns_common.clj:89
error: module-check/src/main/clojure/clojure/core/typed/check_ns_common.clj: patch does not apply
Patch failed at 0001 More fixes for nses with no source
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".
Comment by Allen Rohner [ 05/Mar/15 12:59 PM ]

It looks like the first didn't apply because the code has drifted. Uploaded a second attempt, ctyp-174-2.diff. It should apply cleanly to master, on its own. The change is very simple, it just returns an empty set for the ns deps for closed source nses. The check-ns run looks like:

WARNING:File for datomic.api not found on classpath: datomic/api.clj
Not checking datomic.api (ns form missing)

Comment by Allen Rohner [ 05/Mar/15 1:02 PM ]

I got an ":ok" with the second patch on a 300 line ns that uses datomic.

Comment by Ambrose Bonnaire-Sergeant [ 18/May/15 3:53 AM ]

Applied, will appear in 0.2.89. Thanks!

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

Comment by Mark Wong-VanHaren [ 24/May/15 7:34 PM ]

Might this be related? Thanks!


nickel.core=> (check-ns)
Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 23016.781 msecs"
core.typed initialized.
Start collecting nickel.core
Start collecting nickel.handler
WARNING: File for datomic.api not found on classpath: datomic/api.clj
WARNING: File for datomic.api not found on classpath: datomic/api.clj
Type Error (nickel/handler.clj:30:45) Internal Error (nickel/handler.clj:30:45) Cannot resolve type: datomic.api/Connection
Hint: Is datomic.api/Connection in scope?
Hint: Has datomic.api/Connection's annotation been found via check-ns, cf or typed-deps?

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


Comment by Ambrose Bonnaire-Sergeant [ 24/May/15 8:11 PM ]

No, now we need a set of annotations for datomic.api. Perhaps Allen has some he might open source?

Comment by Mark Wong-VanHaren [ 25/May/15 4:43 AM ]

Ah, I see. Thanks, Ambrose! (I've only started working with core.typed yesterday, so I'm pretty ignorant, but also really jazzed about it. Thanks!)

Comment by Allen Rohner [ 25/May/15 11:08 AM ]

My datomic annotations are pretty basic atm: https://gist.github.com/arohner/d7a6bb057824c224b5b3

That was enough to get me started, but note that d/q returns Any, so you'll have to use something like primsatic/schema if you want to check the results of a query.





[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-172] ExactCount should work with destructuring Created: 25/Aug/14  Updated: 22/Jul/15  Resolved: 22/Jul/15

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

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

Attachments: Text File ctyp-172.patch    
Patch: Code and Test

 Description   

Problem

ExactCount does not work with destructuring.

learning.core=> (cf (fn [[a b] :- (I (Vec Num) (ExactCount 2))] [(+ a b)]))
Type Error (/private/var/folders/34/98dbvkhn7v1clfvl5_y_fkc00001j3/T/form-init2527243481617671751.clj) Static method clojure.lang.Numbers/add could not be applied to arguments:


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

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

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

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



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

Solution

This was fixed sometime before 0.3.8. Adding passing test to close this issue.

Pull request: 35
Patch: ctyp-172.patch
Commit: fb17b8
Release: 0.3.9






[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-170] `(apply concat ...)` gives "AssertionError Assert failed: (r/HeterogeneousMap? kws)". Created: 19/Aug/14  Updated: 20/Jul/15  Resolved: 18/May/15

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

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

OS X, Clojure 1.6.0, core.typed 0.2.66


Attachments: File core.clj     GZip Archive deployer-bug.tar.gz    

 Description   

Trying to type-check `(apply concat [])` or even `(apply concat [["a"] ["b"]])` gives me "AssertionError Assert failed: (r/HeterogeneousMap? kws) clojure.core.typed.type-ctors/HMap->KwArgsSeq (type_ctors.clj:2101)".

Minimal failing example is attached, as well as a tarball of a small project that can be `lein run` to illustrate the error.

Thanks!



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 18/May/15 5:12 AM ]

Fixed for 0.2.89 https://github.com/clojure/core.typed/commit/e47450fcf7093ae2c81ecbc696aa3426075cb7b9

Comment by Tim Dixon [ 18/May/15 11:10 PM ]

Thanks!





[CTYP-169] Type checking fails using core.typed's defn but succeeds without Created: 17/Aug/14  Updated: 30/Dec/14  Resolved: 30/Dec/14

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

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


 Description   

Something seems to be wrong when using core.typed's defn with count:

; this fails type checking
(t/defn f [c :- clojure.lang.Counted] :- t/Int (count c))
 
; but this passes
(t/ann f [clojure.lang.Counted -> t/Int])
(defn f [c] (count c))

The error I get is:

Exception in thread "main" java.lang.IllegalArgumentException: No method in multimethod 'fold-rhs' for dispatch value: [:clojure.core.typed.subst/substitute clojure.core.typed.path_rep.CountPE]

I've posted the whole stack trace here: https://gist.github.com/t6/af21a4f4c6195cd27743



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 30/Dec/14 5:53 PM ]

Fixed for 0.2.75 https://github.com/clojure/core.typed/commit/90d27336fc000ccf47991e22e8f4123812c78205





[CTYP-168] Support metadata map and :arglists in clojure.core.typed/defn Created: 12/Aug/14  Updated: 21/Jul/15  Resolved: 21/Jul/15

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

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

Attachments: Text File 0001-Add-arglists-metadata-to-vars-defined-using-defn.patch     Text File 0002-Add-arglists-metadata-to-vars-defined-using-defn.patch     Text File 0003-Add-arglists-and-attr-map-support-to-defn.patch     Text File ctyp-168.patch    
Patch: Code and Test

 Description   

Minimal example:

(clojure.core/defn f [])
(meta #'f)
;; => {:arglists ([]), ...}

(clojure.core.typed/defn g [])
(meta #'g)
;; => :arglists key missing completely

This is problematic, because g's arguments won't show up in its documentation via e.g. clojure.repl/doc
and I think lots of other tools assume that :arglists is there.

I've attached a patch that should fix this (and have also just signed Clojure's CA).

Pull request: 32
Patch: ctyp-168.patch (deleted a trailing whitespace)
Commit: 73d6be1
Release: 0.3.8



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 12/Aug/14 11:41 AM ]

Is your name on this list? http://clojure.org/contributing

Comment by Ambrose Bonnaire-Sergeant [ 12/Aug/14 11:41 AM ]

Oh I see you just signed it. Let me know when your name pops up and I'll merge this. Thanks!

Comment by Ambrose Bonnaire-Sergeant [ 12/Aug/14 11:43 AM ]

I get some errors in the unit tests. Can you run `mvn test` and fix them please?

Comment by Tobias Kortkamp [ 12/Aug/14 12:15 PM ]

Found the problem and attached a new patch.
The tests pass now..

Comment by Tobias Kortkamp [ 12/Aug/14 11:14 PM ]

I've attached an updated version of the patch that additionally adds attr-map support to defn. The tests still pass and it looks like my name appears on the contributors list now.

Comment by James Reeves [ 04/Jan/15 8:47 PM ]

This would be useful to fix, otherwise docs aren't generated properly when using clojure.core.typed/defn.





[CTYP-167] Several failure cases for comp for polyadic fns and type variables Created: 08/Aug/14  Updated: 20/Jul/15

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

Type: Enhancement Priority: Minor
Reporter: Herwig Hochleitner Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 2
Labels: None


 Description   

Description

comp doesn't work for several common uses

Literal sets can't be used, neither can the well-known identity function

> (cf (comp #{:a :b} identity)
      [Keyword -> (Option Keyword)])

    Type Error (/tmp/form-init7065637308785250377.clj:1:5) Polymorphic function comp could not be applied to arguments:
    Polymorphic Variables:
	    x
	    y
	    b
    Domains:
	    (typ/IFn [x -> y]) (typ/IFn [b ... b -> x])
    Arguments:
	    (typ/HSet #{:b :a}) (All [x] (typ/IFn [x -> x :filters {:then (! (U false nil) 0), :else (is (U false nil) 0)} :object {:id 0}]))
    Ranges:
	    (typ/IFn [b ... b -> y])
    with expected type:
	    (typ/IFn [Keyword -> (Option Keyword)])
    in: (comp #{:b :a} identity)

This seems to be a general problem with polyadic Fns

;; The return type of
> (cf (comp first first))
(typ/IFn [(U nil (I (typ/ExactCount 0) (clojure.lang.Seqable typ/Nothing))) -> nil])
;; seems to be somewhat lacking

;; using it on anything else than empty collections doesn't check
> (cf ((comp first first) []))
nil
> (cf ((comp first first) [[]]))

    Type Error (/tmp/form-init7065637308785250377.clj:1:5) Function (comp first first) could not be applied to arguments:
    Domains:
	    (U nil (I (typ/ExactCount 0) (clojure.lang.Seqable typ/Nothing)))
    Arguments:
	    (HVec [(HVec [])])
    Ranges:
	    nil
    in: ((comp first first) [[]])

;; even the very simple case of
> (cf (comp inc inc))
(typ/IFn [Long -> Long])
;; doesn't do justice 

;; to the magnificent type of
> (cf inc)
(typ/IFn [java.lang.Long -> java.lang.Long] [java.lang.Double -> java.lang.Double] [typ/AnyInteger -> typ/AnyInteger] [java.lang.Number -> java.lang.Number])


 Comments   
Comment by Oskar Wickstrom [ 10/Dec/14 11:03 PM ]

I believe I have some similar problem, but I'm not sure if it's related. I'm not that into type theory so forgive me for any weird explanations. Hope this might add some value to the discussion though.

For better readability see this gist: https://gist.github.com/owickstrom/5695e0591ef245305f27

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

; This seem to work nicely
(t/cf (identity 1)) ;=> [(t/Val 123) {:then tt, :else ff}]
; And this
(t/cf pmap) ;=> (All [c a b ...] (t/IFn [[a b ... b -> c] (t/NonEmptySeqable a) (t/NonEmptySeqable b) ... b -> (t/NonEmptyASeq c)] [[a b ... b -> c] (t/U nil (Seqable a)) (t/U nil (Seqable b)) ... b -> (t/ASeq c)]))
; But when I combine the two...
(t/cf (pmap identity [1 2 3]) ;=> Type Error (/tmp/form-init5174330476817989076.clj:1:7) Polymorphic function pmap could not be applied to arguments:
; ...
; If I pmap using a non-polymorphic (?) function, at least not polymorphic in its range, it seems to work fine.
(t/cf (map println [1 2 3]) ;=>
;2
;1
;3
;(t/NonEmptyASeq nil)
Comment by Marc O'Morain [ 07/May/15 10:19 AM ]

I've hit a similar issue:

This will type-check correctly:

(t/ann keyword-transformer [(t/IFn [String -> String]) ->
                            (t/IFn [t/Keyword -> t/Keyword])])
(defn- keyword-transformer [f]
  (fn [x] (-> x name f keyword)))

whereas this fails:

(t/ann keyword-transformer [(t/IFn [String -> String]) ->
                            (t/IFn [t/Keyword -> t/Keyword])])
(defn- keyword-transformer [f]
  (comp keyword f name))
Type Error (circle/model/settings.clj:19:3) Polymorphic function comp could not be applied to arguments:
Polymorphic Variables:
        x
        y
        b

Domains:
        [x -> y] [b ... b -> x]

Arguments:
        (t/IFn [(t/U t/Symbol java.lang.String t/Keyword) -> t/Keyword] [java.lang.String java.lang.String -> t/Keyword]) [java.lang.String -> java.lang.String] [(t/U clojur
e.lang.Named java.lang.String) -> java.lang.String]

Ranges:
        [b ... b -> y]

with expected type:
        [t/Keyword -> t/Keyword]

in: (comp keyword f name)
in: (comp keyword f name)
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/15 11:27 PM ]

At least one of these problems requires a complete overhaul of the constraint generation algorithm.





[CTYP-166] Core.typed can't check namespaces without source files on the classpath, e.g. datomic Created: 04/Aug/14  Updated: 04/Aug/14  Resolved: 04/Aug/14

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

Type: Defect Priority: Major
Reporter: Allen Rohner Assignee: Allen Rohner
Resolution: Completed Votes: 0
Labels: None

Attachments: File ctyp166-2.diff     Text File ctyp166.patch    
Patch: Code

 Description   

In 0.2.63, core.typed errors out when trying to checking a namespace when the source .clj file isn't present on the classpath:

(ns foo.bar
  (:require [datomic.api :as d]
               [clojure.core.typed :as t]))

=> (t/check-ns 'foo.bar)

Start collecting foo.bar
Type Error (NO_SOURCE_FILE) Internal Error (:<NO LINE>) File for datomic.api not found on classpath: datomic/api.clj
ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.clj:4403)


 Comments   
Comment by Allen Rohner [ 04/Aug/14 3:23 PM ]

The first patch was created improperly. Retry, this time using `git format-patch`

Comment by Ambrose Bonnaire-Sergeant [ 04/Aug/14 3:40 PM ]

Applied, thanks! https://github.com/clojure/core.typed/commit/f13a27622cf75d4f2153bc0c579bf332f9a064ba





[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-164] core.typed: Enhance annotation for clojure.string/blank? Created: 28/Jul/14  Updated: 20/Jul/15  Resolved: 28/Jul/14

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

Type: Enhancement Priority: Trivial
Reporter: Jochen Hinrichsen Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: enhancement

Patch: Code

 Description   

The latest core.typed release 0.2.64-SNAPSHOT contains clojure.string/blank [String -> boolean], this should read clojure.string/blank [(U nil String) -> String].

-clojure.string/blank? [String -> Boolean]
+clojure.string/blank? [(U nil String) -> Boolean]

Pull request available: https://github.com/clojure/core.typed/pull/7/files



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 28/Jul/14 7:08 AM ]

Added myself, thanks!





[CTYP-163] Corrections to a few type signatures for clojure.core functions Created: 19/Jul/14  Updated: 20/Jul/15  Resolved: 20/Jul/14

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

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

Attachments: File ctyp-163-v1.diff    
Patch: Code

 Description   

Was reading through the clojure.core type signatures, and noticed that read-line and printf were incorrect, and format was in there twice. Small patch to correct these things attached.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 3:59 AM ]

Thanks merged https://github.com/clojure/core.typed/commit/87c5812ddd1ec3f336a9e53c9df53f436ec48cc6

read-line also returns nil according to Javadoc, fixed that myself https://github.com/clojure/core.typed/commit/e2eacf39bd494b026cbaccad3e9531cdce4b3332





[CTYP-162] A few annotations were added for clojure.string namespace. Created: 18/Jul/14  Updated: 20/Jul/15  Resolved: 06/Aug/14

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

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

Attachments: File string.diff     File string_updated.diff    
Patch: Code and Test

 Description   

Typed annotations were added for blank?,capitalize,lower-case,replace,reverse and trim.



 Comments   
Comment by Andy Fingerhut [ 19/Jul/14 11:16 AM ]

Aravind, triml and trimr have the same type as trim, and should be easy to add.

clojure.string/replace has a more complex type than [String -> String]. Take a look at the documentation string to get a better idea of what it does. clojure.string/replace-first has the same type signature, so once you get one right you can copy it to the other.

Comment by Aravind K N [ 24/Jul/14 9:32 AM ]

Added annotations for replace-first, triml,trimr and altered the annotation for replace.

Comment by Aravind K N [ 06/Aug/14 8:25 AM ]

This is cleared.
Could someone change it to fixed?

Comment by Ambrose Bonnaire-Sergeant [ 06/Aug/14 9:11 AM ]

Merged, thanks all!





[CTYP-161] "Cannot assoc args" with HMap intersections Created: 09/Jul/14  Updated: 20/Jul/15  Resolved: 20/Jul/14

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

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

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



 Description   
=> (t/cf (assoc (t/ann-form {:foo 1, :bar 2}
                            (t/HMap :mandatory {:foo Number
                                                :bar Number}))
                :baz 3))
[(t/HMap :mandatory {:baz (t/Value 3), :foo java.lang.Number, :bar java.lang.Number}) {:then tt, :else ff}]

=> (t/cf (assoc (t/ann-form {:foo 1, :bar 2}
                            (t/I (t/HMap :mandatory {:foo Number})
                                 (t/HMap :mandatory {:bar Number})))
                :baz 3))
Type Error (/private/var/folders/x2/47j5hlbs01b9b4mjz_8fyf05m8hy4p/T/form-init2093510643541319345.clj:1:7) Cannot assoc args `[(clojure.core.typed/Value :baz) {:then tt, :else ff}] [(clojure.core.typed/Value 3) {:then tt, :else ff}]` on (clojure.core.typed/I (clojure.core.typed/HMap :mandatory {:foo java.lang.Number}) (clojure.core.typed/HMap :mandatory {:bar java.lang.Number}))
ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.clj:4327)



 Comments   
Comment by Timo Mihaljov [ 09/Jul/14 6:15 AM ]

As a workaround, assoc can be replaced with assoc-in. It loses the type and returns Any, but the type can be recovered with an assertion or a postcondition (e.g. {:post [((t/pred MyMap) %)]}).

Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 4:42 AM ]

Fixed, will appear in 0.2.59

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





[CTYP-160] Correctly check IFn ancestor with type/record Created: 04/Jul/14  Updated: 04/Jul/14

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


 Description   

Extending type/record to IFn should be able to verify a type like (IFn [Num -> Num).






[CTYP-159] "swap!" doesn't work anymore due to missing type translation Created: 23/Jun/14  Updated: 18/Apr/15  Resolved: 18/Apr/15

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

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

Clojure 1.6.0, core.typed 0.2.52



 Description   

Minimal test case:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(ns server.minimal
  (:refer-clojure :exclude [doseq let fn dotimes defprotocol loop for])
  (:require [clojure.core.typed :refer :all]))

(ann b (Atom1 (Vec String)))
(def b (atom []))

(swap! b (fn [in] in))

The error message is: "Type Error (server/minimal.clj:8:1) Internal Error (server/minimal.clj:8:1) First argument to TApp must be TFn, actual: clojure.lang.Fn



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 4:44 AM ]

Does this still appear in 0.2.58? It might have been fixed.

Note that the inference for swap! is a bit volatile; you may have to annotate the second argument's parameter types now.

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

In 0.2.80, this type-checks :ok so i think this can be closed

(ns example.core
  (:refer-clojure :exclude [doseq let fn dotimes defprotocol loop for])
  (:require [clojure.core.typed :refer :all]))

(ann b (Atom1 (Vec String)))
(def b (atom []))

(swap! b (fn [in :- (Vec String)] in))




[CTYP-158] Bogus deprecation messages from core.typed Created: 17/Jun/14  Updated: 20/Jul/14  Resolved: 20/Jul/14

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

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


 Description   

"DEPRECATED SYNTAX (client/reactive.clj): Any syntax is deprecated, use clojure.core.typed/Any" - Um, sure?



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 18/Jun/14 3:47 AM ]

There are quite a few of these messages I need to stamp out. What version are you on, and does any particular code trigger it?

Comment by Daniel Ziltener [ 18/Jun/14 5:39 AM ]

I'm on version 0.2.51. There are other such messages, especially core.typed itself triggers a lot of "U syntax is deprecated, use clojure.core.typed/U" messages.

Comment by Sean Corfield [ 25/Jun/14 11:33 AM ]

Repro for 0.2.52:

  • lein new app typed-test
  • edit project.clj and add [org.clojure/core.typed "0.2.52"] as a dependency and {{:plugins [[lein-typed "0.3.4"]]}}
  • edit src/typed_test/core.clj and add {{(:require [clojure.core.typed])}}
  • run lein typed check typed-test.core

You get this output:

DEPRECATED SYNTAX (typed_test/core.clj): Any syntax is deprecated, use clojure.core.typed/Any

This comes from parse-unparse/parse-type-symbol 'Any but I haven't been able to figure out what triggers it yet. It's clearly not triggered by anything in user code tho' since it happens even when user code does not mention Any.

Comment by Sean Corfield [ 25/Jun/14 11:41 AM ]

Found it: line 58 of analyze_clj.clj uses ~'Any but it should use T/Any.

I made that one change locally and installed 0.2.53-SNAPSHOT and the warning goes away for my test case when I depend on the snapshot.

Comment by Ambrose Bonnaire-Sergeant [ 02/Jul/14 8:55 AM ]

I believe I stamped out all of these bogus messages in 0.2.53. Please let me know.

Comment by Sean Corfield [ 02/Jul/14 5:53 PM ]

I no longer see any deprecation warnings with 0.2.53 against our codebase. Thank you!





[CTYP-157] Fails to properly load protocols as soon as a ns containing a protocol is required from another checked ns Created: 17/Jun/14  Updated: 20/Jul/15  Resolved: 20/Jul/14

Status: Closed
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: Completed Votes: 0
Labels: None
Environment:

Linux, Java 8.



 Description   

Minimal test case: https://gist.github.com/zilti/ac127170605600d008bb



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 5:30 AM ]

I believe this is fixed with lein-typed 0.3.5.

Please try it.





[CTYP-156] Add special arities to `nth` if we know exactly the index argument and CountRange Created: 15/Jun/14  Updated: 15/Jun/14

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

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

Attachments: Text File 0001-Add-special-arities-to-nth-if-we-know-exactly-the-in.patch    
Patch: Code and Test

 Description   

(nth (I (Coll Integer) (CountRange 1)) 0 x) should always return Integer, not (U Integer x)






[CTYP-155] Unit test that might be doing nothing Created: 12/Jun/14  Updated: 20/Jul/14  Resolved: 20/Jul/14

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

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


 Description   

In namespace clojure.core.typed.test.parse-unparse-test the following test appears to be calling = with 1 argument, which always returns true:

(is-clj (= (clj (-> (unparse-type (parse-type `(t/TFn ~'[[a :variance :covariant]] ~'a)))
                      next)
             (quote ([[a :variance :covariant]] a)))))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 5:57 AM ]

Thanks fixed.





[CTYP-154] A few more issues discovered via linting Created: 10/Jun/14  Updated: 10/Jun/14  Resolved: 10/Jun/14

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

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


 Description   

I can include a patch if you want, but given that you may want to make some but not all of these changes, I will just describe them for now.

src/main/clojure/clojure/core/typed.clj has two nearly identical occurrences of function reset-cache. One returns nil explicitly, the other does not. Best to have only one implementation.

src/main/clojure/clojure/core/typed/check.clj has an expression (assoc-in [:types kt] vt) that appears to be the wrong number of args for assoc-in. I am not sure what is intended there.

src/main/clojure/clojure/core/typed/errors.clj has two def's for int-error-kw. One would be better.

src/main/clojure/clojure/core/typed/subtype.clj has an expression (and (r/HSet? s)) that could be replaced with (r/HSet? s)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 10/Jun/14 10:58 PM ]

Fixed, thanks!





[CTYP-153] Consider renaming add-to-alias-env's first arg (currently &form) Created: 10/Jun/14  Updated: 10/Jun/14  Resolved: 10/Jun/14

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

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

Attachments: File ctyp-153-v1.diff    

 Description   

The change I am suggesting here may be a bug, and I simply do not realize it yet.

clojure.core/defn checks whether the first arg is called

&form
, and if so, it removes the first two args from the arg vector to create the value for the :arglists key of the var's metadata. I believe this is because almost every time the first arg is called
&form
, it is a function created by a macro definition, and the first two args are
&form &env
, and Clojure programmers would typically prefer not to see those hidden args when they do (doc name-of-macro).

Function clojure.core.typed/add-to-alias-env has a first arg

&form
, and thus its :arglists are set to
[t]
rather than
[&form qsym t]
. I don't think there is any bug here, but if it is correct to change the name of the first arg to something else, e.g.
form
, the :arglists would be closer to what one would expect.

The only reason I noticed this is due to a bunch of :wrong-arity warnings from Eastwood when linting core.typed, since the situation described above means that it appears that all calls to add-to-alias-env with the correct number (3) of args appear to be the wrong number of args.



 Comments   
Comment by Andy Fingerhut [ 10/Jun/14 11:34 AM ]

Patch ctyp-153-vv1.diff renames the first arg of add-to-alias-env from &form to form.

Comment by Ambrose Bonnaire-Sergeant [ 10/Jun/14 11:38 AM ]

Thanks, renamed.





[CTYP-152] base_env_cljs.clj lacks annotations for several cljs.core fns Created: 10/Jun/14  Updated: 21/Aug/14  Resolved: 21/Aug/14

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

Type: Task Priority: Minor
Reporter: Minori Yamashita Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: cljs, enhancement
Environment:

master branch as of 6/10/2014


Attachments: Text File ympbyc-cljs-core-annotations.patch    

 Description   

base_env_cljs.clj is supposed to have annotations for all functions in cljs.core. Currently, limited number of functions got annotations.



 Comments   
Comment by Minori Yamashita [ 03/Aug/14 11:07 AM ]

I Attach current diff between ympbyc/core.typed and clojure/core.typed.

here's my branch which has been rebased to clojure/core.typed/tree/master
https://github.com/ympbyc/core.typed/tree/master

Comment by Ambrose Bonnaire-Sergeant [ 21/Aug/14 11:07 AM ]

Merged for 0.2.67.





[CTYP-151] A few small problems found by linting core.typed Created: 09/Jun/14  Updated: 10/Jun/14  Resolved: 10/Jun/14

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

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

Attachments: Text File ctyp-fixes.patch    

 Description   

Most of the problems changed by the attached patch are calling functions with incorrect arity, or incorrectly placed doc strings (wrong order relative to the function/macro arg vector).



 Comments   
Comment by Andy Fingerhut [ 09/Jun/14 8:46 AM ]

Also remove duplicate definition of function rseqv.

Comment by Andy Fingerhut [ 09/Jun/14 8:48 AM ]

Latest release of Eastwood linter doesn't work on core.typed yet – these were found with a pre-release of the next version, which should do better.

Comment by Ambrose Bonnaire-Sergeant [ 10/Jun/14 2:21 AM ]

Merged thanks!





[CTYP-150] Fix constraint generation with intersections Created: 08/Jun/14  Updated: 20/Jul/14  Resolved: 20/Jul/14

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   

Unit tests involving intersections often randomly fail. I think we need to carefully reconsider the constraint resolution algorithm cases for intersections, in particular we need to be more consistent about which combinations of intersection members we use in the final cset.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 08/Jun/14 3:01 PM ]

Relevant: https://github.com/clojure/core.typed/commit/fe91e01855ec387ed5d1e30f4fe079d70782ffa7

Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 5:33 AM ]

Intersections are now ordered.





[CTYP-149] namespace check-ns-common has unnecessary dependency on itself Created: 03/Jun/14  Updated: 04/Jun/14  Resolved: 03/Jun/14

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

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

Attachments: Text File fix.patch    

 Description   

Discovered while attempting to run Eastwood on unmodified core.typed



 Comments   
Comment by Andy Fingerhut [ 03/Jun/14 4:07 PM ]

Patch fix.patch removes the unnecessary and unused :require line. Its presence causes tools.namespace and tools based on them, e.g. Eastwood, to throw an exception due to a circular dependency.

Comment by Ambrose Bonnaire-Sergeant [ 03/Jun/14 9:14 PM ]

Thanks, and apologies to Eastwood! Merged.

Comment by Andy Fingerhut [ 04/Jun/14 2:01 PM ]

Thanks for the change, but there is no need to apologies to Eastwood It still has rough edges all over the place where code that the Clojure compiler handles causes Eastwood to throw exceptions for various reasons, and not all of them are because the Clojure compiler is lenient.





[CTYP-148] `nthnext` should better understand heterogenous vectors Created: 31/May/14  Updated: 01/Jun/14  Resolved: 01/Jun/14

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

Type: Enhancement Priority: Trivial
Reporter: Jake Goulding Assignee: Jake Goulding
Resolution: Completed Votes: 0
Labels: None

Attachments: File nthnext.diff    

 Description   

Specifically, I want something like this to work:

(fn [stmt :- '[Any Long]]
  (let [[_ & body] stmt)]
    (ann-form body (HSeq [Long]))))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 01/Jun/14 12:40 PM ]

Merged.





[CTYP-147] Atom validation failure Created: 26/May/14  Updated: 27/May/14  Resolved: 27/May/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


 Description   

On trying to upgrade my core.typed from 0.2.41 to 0.2.48, I get the following when running `lein test` (which has only one test that does check-ns):

lein test controller.core-test
Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 5229.278612 msecs"
core.typed initialized.
Start collecting controller.core
Start collecting controller.persistence
Start collecting controller.types
Finished collecting controller.types
Finished collecting controller.persistence
Start collecting controller.reading
Start collecting controller.util
Finished collecting controller.util
Start collecting controller.protocols
Finished collecting controller.protocols
DEPRECATED SYNTAX  ( controller/reading.clj : 15 :1 ) : Vector* is deprecated, see clojure.core.typed/HVec
Finished collecting controller.reading
Start collecting controller.twitter
Start collecting clojure.core.typed.async
Finished collecting clojure.core.typed.async
Finished collecting controller.twitter
Start collecting controller.security
Finished collecting controller.security
Start collecting controller.dave-peck-go
Start collecting controller.memoize
Finished collecting controller.memoize
Finished collecting controller.dave-peck-go
Start collecting controller.alerts
Finished collecting controller.alerts
Start collecting controller.server
DEPRECATED SYNTAX  ( controller/server.clj : 24 :1 ) : Vector* is deprecated, see clojure.core.typed/HVec
DEPRECATED SYNTAX  ( controller/server.clj : 24 :1 ) : Vector* is deprecated, see clojure.core.typed/HVec
Finished collecting controller.server

lein test :only controller.core-test/type-check

ERROR in (type-check) (ARef.java:33)
expected: (t/check-ns (quote controller.core))
  actual: java.lang.IllegalStateException: Invalid reference state
 at clojure.lang.ARef.validate (ARef.java:33)
    clojure.lang.ARef.validate (ARef.java:46)
    clojure.lang.Atom.swap (Atom.java:80)
    clojure.core$swap_BANG_.doInvoke (core.clj:2235)
    clojure.lang.RestFn.invoke (RestFn.java:497)
    clojure.core.typed.ns_deps$add_ns_deps.invoke (ns_deps.clj:42)
    clojure.core.typed.collect_phase/fn (collect_phase.clj:178)
    clojure.lang.MultiFn.invoke (MultiFn.java:227)
    clojure.core.typed.collect_phase$visit_do.invoke (collect_phase.clj:163)
    clojure.core.typed.collect_phase$collect _COLON_do18474.invoke (collect_phase.clj:225)
    clojure.lang.MultiFn.invoke (MultiFn.java:227)
    clojure.core.typed.collect_phase$collect_asts.invoke (collect_phase.clj:149)
    clojure.core.typed.collect_phase$collect_ns.invoke (collect_phase.clj:130)
    clojure.core.typed$check_ns_info$do_collect__1204.invoke (typed.clj:2431)
    clojure.core.typed$check_ns_info$do_check_ns__1253.invoke (typed.clj:2465)
    clojure.core.typed$check_ns_info.doInvoke (typed.clj:2476)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.core$apply.invoke (core.clj:626)
    clojure.core.typed$check_ns.doInvoke (typed.clj:2527)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.core$apply.invoke (core.clj:624)
    controller.core_test/fn (core_test.clj:6)
    clojure.test$test_var$fn__7187.invoke (test.clj:704)
    clojure.test$test_var.invoke (test.clj:704)
    clojure.test$test_vars$fn__7209$fn__7214.invoke (test.clj:722)
    clojure.test$default_fixture.invoke (test.clj:674)
    clojure.test$test_vars$fn__7209.invoke (test.clj:722)
    clojure.test$default_fixture.invoke (test.clj:674)
    clojure.test$test_vars.invoke (test.clj:718)
    clojure.test$test_all_vars.invoke (test.clj:728)
    clojure.test$test_ns.invoke (test.clj:747)
    clojure.core$map$fn__4245.invoke (core.clj:2559)
    clojure.lang.LazySeq.sval (LazySeq.java:40)
    clojure.lang.LazySeq.seq (LazySeq.java:49)
    clojure.lang.Cons.next (Cons.java:39)
    clojure.lang.RT.boundedLength (RT.java:1654)
    clojure.lang.RestFn.applyTo (RestFn.java:130)
    clojure.core$apply.invoke (core.clj:626)
    clojure.test$run_tests.doInvoke (test.clj:762)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:624)
    user$eval558$fn__613$fn__644.invoke (form-init2987814106291818777.clj:1)
    user$eval558$fn__613$fn__614.invoke (form-init2987814106291818777.clj:1)
    user$eval558$fn__613.invoke (form-init2987814106291818777.clj:1)
    user$eval558.invoke (form-init2987814106291818777.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:6703)
    clojure.lang.Compiler.eval (Compiler.java:6693)
    clojure.lang.Compiler.load (Compiler.java:7130)
    clojure.lang.Compiler.loadFile (Compiler.java:7086)
    clojure.main$load_script.invoke (main.clj:274)
    clojure.main$init_opt.invoke (main.clj:279)
    clojure.main$initialize.invoke (main.clj:307)
    clojure.main$null_opt.invoke (main.clj:342)
    clojure.main$main.doInvoke (main.clj:420)
    clojure.lang.RestFn.invoke (RestFn.java:421)
    clojure.lang.Var.invoke (Var.java:383)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)

Ran 1 tests containing 1 assertions.
0 failures, 1 errors.


 Comments   
Comment by Gary Fredericks [ 26/May/14 10:12 PM ]

If you bug me about this enough I will try to get a minimal reproducing case.

Comment by Ambrose Bonnaire-Sergeant [ 26/May/14 11:07 PM ]

Please also try 0.2.{49,50}.

Comment by Gary Fredericks [ 27/May/14 6:36 AM ]

49 and 50 both work, so I'll just go straight to 50. I did not think to try either of those because the readme still points to 48.

Thanks!





[CTYP-146] java.lang.AssertionError: Assert failed: (<= (count s) cnt) Created: 26/May/14  Updated: 20/Jul/15  Resolved: 27/May/14

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

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

OSX


Attachments: Text File core-typed-bug.txt    

 Description   

With core.typed 0.2.50 I get this exception:

Exception in thread "main" java.lang.AssertionError: Assert failed: (<= (count s) cnt)
        at clojure.core.typed.cs_gen$pad_right.invokePrim(cs_gen.clj:1252)
        at clojure.core.typed.cs_gen$cs_gen_Function.invoke(cs_gen.clj:1296)
        at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter__11317__11321$fn__11322$fn__11323$fn__11324$iter__11325__11329$fn__11330$fn__11331$fn__11332$fn__11333.invoke(cs_gen.clj:864)
        at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter__11317__11321$fn__11322$fn__11323$fn__11324$iter__11325__11329$fn__11330$fn__11331$fn__11332.invoke(cs_gen.clj:863)
        at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter__11317__11321$fn__11322$fn__11323$fn__11324$iter__11325__11329$fn__11330$fn__11331.invoke(cs_gen.clj:861)
        at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter__11317__11321$fn__11322$fn__11323$fn__11324$iter__11325__11329$fn__11330.invoke(cs_gen.clj:861)
...

When type-checking this code (either from lein typed (0.3.4) or the Emacs plugin):

(ns demo
  (:require [clojure.core.typed :refer [ann Seq Option]]))

(ann distinct-except
  (All [x]
       [[x -> Boolean] (Option (Seq x)) -> (Option (Seq x))]))
(defn distinct-except
  "Same as distinct, but keeps duplicates if they pass exception?"
  [exception? [head & tail :as coll]]
  (lazy-seq
   (when head
     (cons head
           (distinct-except exception?
                            (if (exception? head)
                              tail
                              (remove (partial = head) tail)))))))

I get the same exception if I just (cf ...) the defn too. I've attached the full stacktrace. Let me know if there's anything else I can helpfully supply.



 Comments   
Comment by Kris Jenkins [ 26/May/14 2:49 PM ]

Oh, sorry - Jira code formatting. Here's that code again:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(ns demo
  (:require [clojure.core.typed :refer [ann Seq Option]]))

(ann distinct-except
  (All [x]
       [[x -> Boolean] (Option (Seq x)) -> (Option (Seq x))]))
(defn distinct-except
  "Same as distinct, but keeps duplicates if they pass exception?"
  [exception? [head & tail :as coll]]
  (lazy-seq
   (when head
     (cons head
           (distinct-except exception?
                            (if (exception? head)
                              tail
                              (remove (partial = head) tail)))))))
Comment by Ambrose Bonnaire-Sergeant [ 27/May/14 11:48 AM ]

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





[CTYP-145] Offer separate zero-dependency artifact Created: 26/May/14  Updated: 20/Jul/15  Resolved: 20/Jul/14

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

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

Attachments: File CTYP-145-1.diff     File CTYP-145.diff    
Patch: Code

 Description   

The objective here is to be able to apply typed-clojure to libraries, without having their downstream dependents require the typed-clojure dependency as well. The libraries in question would then be able to fold in a separate TC dependency (which would bring in e.g. analyzer, ClojureScript, etc) for doing the actual type checking at test-time, in addition to their "regular" tests which would be run without the TC machinery. (Leiningen profiles would be ideal for setting up these different sorts of testing contexts.)

Tasks include:

1. Defining a "top-level" zero-dependency namespace(s) that provides all of the user-facing type-annotation macros (which must be no-ops when evaluated outside of a type-checking process).
2. Modifying the TC pom.xml and other project configuration so that two dependencies are produced; one without dependencies containing only the above-noted namespace(s), and another that depends upon the first and which also carries the necessary dependencies for actually performing type checking.

Namespaces to be included in no-dep jar:

src/main/clojure/clojure/core/typed.clj
src/main/clojure/clojure/core/typed/internal.clj
src/main/clojure/clojure/core/typed/current_impl.clj
src/main/clojure/clojure/core/typed/profiling.clj
src/main/clojure/clojure/core/typed/util_vars.clj
src/main/clojure/clojure/core/typed/profiling.clj
src/main/clojure/clojure/core/typed/errors.clj
src/main/clojure/clojure/core/typed/coerce_utils.clj
src/main/clojure/clojure/core/typed/ast_utils.clj
src/main/clojure/clojure/core/typed/type_contract.clj
src/main/clojure/clojure/core/typed/load_if_needed.clj
;; TODO: ClojureScript stuff


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 26/May/14 6:30 AM ]

Namespaces that should go in the zero-dep jar:

src/main/clojure/clojure/core/typed.clj
src/main/clojure/clojure/core/typed/internal.clj
src/main/clojure/clojure/core/typed/current_impl.clj
src/main/clojure/clojure/core/typed/profiling.clj
src/main/clojure/clojure/core/typed/util_vars.clj
src/main/clojure/clojure/core/typed/errors.clj
src/main/clojure/clojure/core/typed/coerce_utils.clj
src/main/clojure/clojure/core/typed/ast_utils.clj
Comment by Chas Emerick [ 26/May/14 7:25 AM ]

From ambrosebs in #typed-clojure: the name of the no-deps artifact will be core.typed.rt.

Comment by Ambrose Bonnaire-Sergeant [ 26/May/14 11:02 AM ]

Removed tools.analyzer dep https://github.com/clojure/core.typed/commit/b35131e503547d46e13ec9d50f7def84ebd8db04

Comment by Chas Emerick [ 28/May/14 8:59 AM ]

It looks like we need to produce four artifacts now: core.typed and core.typed.rt, in "regular" and "slim". Does this sound right?

Comment by Ambrose Bonnaire-Sergeant [ 28/May/14 9:14 AM ]

I guess so. I'm not sure we need core.typed.rt "regular", but it might be useful.

Comment by Chas Emerick [ 28/May/14 12:23 PM ]

For those looking on, the WIP patch is here:

https://github.com/cemerick/core.typed/commit/0cd50d09fa17b9c833066b4cf9db7457b8e7f959

A project that uses the new "rt" zero-dep artifact to enable annotations without requiring downstream dependents to depend upon core-typed is here:

https://github.com/cemerick/pprng/tree/WIP-typed-clojure

Official patch to be attached shortly.

Comment by Ambrose Bonnaire-Sergeant [ 28/May/14 1:55 PM ]

Added load_if_needed.clj (latest master).

Comment by Chas Emerick [ 29/May/14 6:15 AM ]

Patch attached. When additional namespaces should be added to the core.typed.rt artifact, just add them to the listing in module-rt/pom.xml.

core.typed installs locally just fine with this patch, but there's no easy way for me to test it in the Jenkins/build.clojure.org environment. Only one way to find out if it plays nice there.

Comment by Chas Emerick [ 29/May/14 10:56 AM ]

Attached an additional patch ({{CTYP-145-1.diff}}) that adds a minimal test to ensure that core.typed.rt can load. This will catch cases when that subset of typed-clojure expands, but e.g. the file list in module-rt/pom.xml hasn't been updated to match.

Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 5:32 AM ]

org.clojure/core.typed.rt now lives!





[CTYP-144] Numeric types assigned to protocol method argument not recognized in inline defrecord implementation Created: 22/May/14  Updated: 24/May/14  Resolved: 24/May/14

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

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


 Description   

In summary:

(tc/defprotocol IRandom
(-seed [this] :- tc/AnyInteger)
(-next-double [this] :- Double)
(-next-float [this] :- Float)
(-next-int
  [this] :- Integer
  [this limit :- Integer] :- Integer)
(-next-long [this] :- Long)
(-next-boolean [this] :- Boolean))
 
(tc/ann-record SeededRandom [seed :- tc/AnyInteger
                             rng :- java.util.Random])
 
#+clj
(defrecord SeededRandom [seed ^Random rng]
IRandom
(-seed [this] seed)
(-next-double [this] (.nextDouble rng))
(-next-float [this] (.nextFloat rng))
(-next-int [this] (.nextInt rng))
(-next-int [this limit] (.nextInt rng limit))
(-next-long [this] (.nextLong rng))
(-next-boolean [this] (.nextBoolean rng)))
 
 
-----------------
 
Type Error (cemerick/pprng.clj:43:27) Instance method java.util.Random/nextInt could not be applied to arguments:
 
 
Domains:
int
 
Arguments:
Object
 
Ranges:
int
 
with expected type:
(U Object nil)
 
in: (.nextInt rng limit)

-next-int's argument is typed as Integer, as confirmed by cf:

cemerick.pprng=> (tc/cf -next-int)
(Fn [IRandom -> java.lang.Integer] [IRandom java.lang.Integer -> java.lang.Integer])

To reproduce, clone pprng (note the WIP-typed-clojure branch). The project uses cljx, so you probably should run lein cljx auto while you're tinkering with the source so that the cljx transformation is run automatically in between your running (check-ns) (cljx doesn't generally require preprocessing, but TC seems to always reload definitions from disk and doesn't support REPL interactions based on in-file annotations.) Then:

$ lein with-profile TC repl
...
=> (require 'cemerick.pprng)
=> (in-ns 'cemerick.pprng)
=> (tc/check-ns)


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 22/May/14 12:39 PM ]

Minimum failing case: https://gist.github.com/frenchy64/076d25450eed8f80aabe

Comment by Chas Emerick [ 24/May/14 9:22 AM ]

Confirmed that this is fixed in 0.2.50, via https://github.com/clojure/core.typed/commit/203e0f2787fcb481a67e7e03c5a97a64f89e488b

Thanks!





[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-142] Support a Path Element for first/second/nth Created: 11/May/14  Updated: 08/Jun/14  Resolved: 08/Jun/14

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

Type: Enhancement Priority: Minor
Reporter: Jake Goulding Assignee: Jake Goulding
Resolution: Completed Votes: 0
Labels: None

Attachments: File nth-path-expr.diff    

 Description   

What I tried:

(def-alias Statement
  (U
   '[':params String]
   '[':no-params]))

(ann unpack-vector [Statement -> Any])
(defn unpack-vector [stmt]
  (let [key (first stmt)]
    (if (= :params key)
      (let [param (second stmt)]
        (ann-form param String)))))

I expected this to type-check. Instead, I got:

Type Error (typed_mm/core.clj:14:9) Local binding param__#0 expected type java.lang.String, but actual type (t/Option (U (Value :params) (Value :no-params) String))
in: param
 
 
Type Error (typed_mm/core.clj:14:19) Type mismatch:
 
Expected: 	java.lang.String
 
Actual: 	(t/Option (U (Value :params) (Value :no-params) String))
in: param

I could understand core.typed thinking it could be `nil` if it looked at both members of the union, but it is very strange to me that it thinks the second item in the vector could be :params or :no-params, as those should only occur in the first position...

(With version 0.2.45-20140511.165157-12)



 Comments   
Comment by Jake Goulding [ 11/May/14 7:08 PM ]

It's actually the same for heterogenous maps as well:

(def-alias Statement
  (U (HMap :mandatory {:op ':params
                       :val String}
           :complete? true)
     (HMap :mandatory {:op ':no-params}
           :complete? true ) ))

(ann unpack-map [Statement -> Any])
(defn unpack-map [stmt]
  (let [key (:op stmt)]
    (if (= :params key)
      (let [param (:val stmt)]
        (ann-form param String)))))

With error:

Type Error (NO_SOURCE_FILE:13:9) Local binding param__#0 expected type java.lang.String, but actual type (U nil String)
in: param

Type Error (NO_SOURCE_FILE:13:19) Type mismatch:

Expected:       java.lang.String

Actual:         (U nil String)
in: param
Comment by Jake Goulding [ 11/May/14 7:14 PM ]

Perhaps this isn't something that's possible right now? As a human, I know that (:op stmt) can only take one of two values, each of which uniquely picks between the union values. I think this would involve changing variable stmt based on information from key, which I have yet to find in the source code.

Comment by Ambrose Bonnaire-Sergeant [ 12/May/14 1:34 AM ]

I don't expect the HVec case to work yet.

I explain how it might be implemented from [12:01:38] http://logs.lazybot.org/irc.freenode.net/%23typed-clojure/2014-05-11.txt

The HMap case also fails for me. Looks like core.typed is sensitive to order or something, because rearranging it like this checks fine:

(ns clojure.core.typed.test.hmap-branch
  (:require [clojure.core.typed :as t]))

(t/def-alias Statement
  (U (HMap :mandatory {:op ':params
                       :val String}
           :complete? true)
     (HMap :mandatory {:op ':no-params}
           :complete? true ) ))

(t/ann unpack-map2 [Statement -> Any])
(defn unpack-map2 [stmt]
  (when (= (:op stmt) :params)
    (let [param (:val stmt)]
      (t/ann-form param String))))
Comment by Jake Goulding [ 31/May/14 5:33 PM ]

Added a patch with some initial refactoring to cleanup the implementation of check.nth. Useful implementation is still being worked on.

Comment by Ambrose Bonnaire-Sergeant [ 08/Jun/14 3:02 PM ]

Merged. I also made the overlap case more accurate: https://github.com/clojure/core.typed/commit/623bfe0918036ea8aa1f5496e268d8b1dfdf0db5

Thanks!





[CTYP-141] Implement Difference type Created: 09/May/14  Updated: 20/Jul/15  Resolved: 20/Jul/15

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 [ 20/Jul/15 11:14 AM ]

This was implemented sometime in 2014, but is fairly undocumented and not really supported. Once support for negation types is better supported by the constraint generation algorithm (cs_gen.clj), we should reconsider fully supporting this feature.





[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-139] Extend what can used as HMap key Created: 07/May/14  Updated: 07/May/14

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


 Description   

We should model how `equiv` works at the type level for HMap keys. It would be nice if we can define equality for custom defrecord/deftype's.

This will help understand Schema definitions automatically.






[CTYP-138] Support mutually recursive types Created: 07/May/14  Updated: 07/May/14

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


 Description   

Some notes from asumu: https://botbot.me/freenode/racket/msg/14338467/






[CTYP-137] annotation for mapv does not leverage non-empty collections Created: 04/May/14  Updated: 31/May/14  Resolved: 31/May/14

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

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

Attachments: File non-empty-mapv.diff    

 Description   

After hacking around CTYP-136, I tried this code:

(ann bar [(t/Coll t/AnyInteger) -> (U (Value :empty) t/AnyInteger)])
(defn bar [c]
  (if (seq c)
    (last (mapv inc c))
    :empty))

But got

Expected:       (U Long Integer BigInteger BigInt Byte Short (Value :empty))
Actual:         (U Long Integer BigInteger BigInt Byte Short (Value :empty) nil)

Re annotating as this worked around my problem:

(ann clojure.core/mapv
 (All [c a b ...]
    (Fn
     [[a b ... b -> c] (t/NonEmptySeqable a) (t/NonEmptySeqable b) ... b -> (t/NonEmptyVec c)]
     [[a b ... b -> c] (U nil (t/Seqable a)) (U nil (t/Seqable b)) ... b -> (clojure.lang.APersistentVector c)])))


 Comments   
Comment by Jake Goulding [ 31/May/14 11:56 AM ]

As discussed, I've added AVec and NonEmptyAVec and then used that instead.

Comment by Ambrose Bonnaire-Sergeant [ 31/May/14 12:24 PM ]

Thanks! Merged.





[CTYP-136] annotation for last does not leverage non-empty collections Created: 04/May/14  Updated: 31/May/14  Resolved: 31/May/14

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

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

Attachments: File non-empty-last.diff    

 Description   

I expected this to be all right:

(ann foo [(t/Coll t/AnyInteger) -> (U (Value :empty) t/AnyInteger)])
(defn foo [c]
  (if (seq c)
    (last c)
    :empty))

But I get this error:

Expected:       (U Long Integer BigInteger BigInt Byte Short (Value :empty))
Actual:         (U Long Integer BigInteger BigInt Byte Short (Value :empty) nil)

Reannotating last as this causes it to work:

(ann clojure.core/last
  (All [x]
       (Fn
        [(t/NonEmptySeqable x) -> x]
        [(t/Option (t/Seqable x)) -> (U nil x)])))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 31/May/14 12:51 PM ]

Merged.





[CTYP-135] pred does not create proper filters Created: 04/May/14  Updated: 31/May/14  Resolved: 31/May/14

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

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


 Description   

Here is original example code to reproduce: https://gist.github.com/shepmaster/234a90b439e0585f0ec5

A smaller version is:

(def-alias Thing '{:thing Any})

(ann thing? (predicate Thing))
(def thing? (t/pred Thing))
Expected:       (Fn [Any -> Boolean :filters {:then (is Thing 0), :else (! Thing 0)}])

Actual:         (Fn [Any -> Boolean :filters {:then (is nil 0), :else (! nil 0)}])
in: (def thing? (clojure.core.typed/pred* (quote Thing) (quote typed.core) (fn* ([arg3662] (clojure.lang.RT/booleanCast ((clojure.core.typed.current-impl/hmap-c? :mandatory {:thing (fn* ([G__3663] true))\
} :optional {} :absent-keys #{} :complete? false) arg3662))))))


 Comments   
Comment by Jake Goulding [ 25/May/14 3:52 PM ]

I think this was fixed in commit ebaedae46704e40aa9479c457e88ca4536eeb232, released in 0.2.45.





[CTYP-134] Allow namespace aliases in `ann` Created: 14/Apr/14  Updated: 20/Jul/15

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

Type: Enhancement Priority: Minor
Reporter: Oskar Thorén Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 1
Labels: