<< Back to previous view

[CTYP-164] core.typed: Enhance annotation for clojure.string/blank? Created: 28/Jul/14  Updated: 28/Jul/14  Resolved: 28/Jul/14

Status: Resolved
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/14  Resolved: 20/Jul/14

Status: Resolved
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: 24/Jul/14

Status: Open
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: Unresolved 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.





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

Status: Resolved
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: 20/Jul/14

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

Type: Defect Priority: Critical
Reporter: Daniel Ziltener Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved 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.





[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.0
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/14  Resolved: 20/Jul/14

Status: Resolved
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: 10/Jun/14

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

master branch as of 6/10/2014



 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 [ 10/Jun/14 6:39 AM ]

I added (probably incomplete) annotations for several sequential fns (first, rest, last, butlast) and tests for those.
https://github.com/ympbyc/core.typed/commit/35dfd799ebd2cff1e1c5fd385cc20a10eb865065





[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: 27/May/14  Resolved: 27/May/14

Status: Resolved
Project: core.typed
Component/s: None
Affects Version/s: 0.2.0
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_1131711321$fn11322$fn11323$fn11324$iter1132511329$fn11330$fn11331$fn11332$fn_11333.invoke(cs_gen.clj:864)
at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter_1131711321$fn11322$fn11323$fn11324$iter1132511329$fn11330$fn11331$fn_11332.invoke(cs_gen.clj:863)
at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter_1131711321$fn11322$fn11323$fn11324$iter1132511329$fn11330$fn_11331.invoke(cs_gen.clj:861)
at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter_1131711321$fn11322$fn11323$fn11324$iter1132511329$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/14  Resolved: 20/Jul/14

Status: Resolved
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: 12/May/14

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

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: 09/May/14

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





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

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





[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: 14/Apr/14

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

Type: Enhancement Priority: Minor
Reporter: Oskar Thorén Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 1
Labels: None


 Description   

If I have a function which uses an external library, I want to be able to write:

(ann ^:no-check json/parse-string [String Boolean -> Map])

instead of

(ann ^:no-check cheshire.core/parse-string [String Boolean -> Map])

since that's the form I use in my namespace.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 14/Apr/14 6:43 AM ]

This might also apply to `ann-protocol`.





[CTYP-133] Typechecker fails when checking involves an object from reify Created: 13/Apr/14  Updated: 25/Jul/14

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: 1
Labels: bug
Environment:

Clojure 1.6.0, core.typed 0.2.44



 Description   

The error message is

No method in multimethod 'check' for dispatch value: :reify

The following is a minimal test case which fails:

core.clj
(ns core-typed-bug.core
  (:require [clojure.core.typed :refer :all]))

(ann-protocol ITypedTest
              get-data [ITypedTest -> Any])
(defprotocol> ITypedTest
  (get-data [this]))

(ann typed-test [String -> ITypedTest])
(defn typed-test [input]
  (reify ITypedTest
    (get-data [_] input)))

(defn> testfn :- Any
  [asdf :- Keyword, in :- ITypedTest]
  (get-data in))

Likely similar to bug http://dev.clojure.org/jira/browse/CTYP-132



 Comments   
Comment by Jochen Hinrichsen [ 25/Jul/14 4:36 AM ]

Also on clojure 1.5.1, core.typed 0.2.65

No method in multimethod 'check' for dispatch value: :reify





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

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

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

Clojure 1.6.0, core.typed 0.2.44



 Description   

The error message is

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

The following is a minimal test case which fails:

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

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



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

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

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

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

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

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

As of version 0.2.51, this still happens reliably.





[CTYP-131] Support (apply f (apply concat hmap)) Created: 31/Mar/14  Updated: 31/Mar/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   

Started work on turning (apply concat hmap) into a KwArgsSeq https://github.com/clojure/core.typed/commit/8f38ee9c018a56beae57e1639401919f4ce8c0f2

Need to utilise this information in check-apply.






[CTYP-130] add HSequential type Created: 31/Mar/14  Updated: 10/Apr/14  Resolved: 10/Apr/14

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

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

Attachments: Text File ambrose-hsequential-v3-1.patch     Text File ambrose-various-fixes.patch     File hsequential-demo.diff     File hsequential.diff     File hsequential-v2.diff     File hsequential-v3.diff    

 Description   

Hi, Ambrose

I've implemented part of HSequential as we discussed in CTYP-126.

But currently

(t/cf (fn [& y] (if (empty? y) nil (first y))))

will got Type error, saying

(I (HSequential [Any *]) clojure.core.typed/NonEmptyCount)

can't be applied to

(HSequential [x Any *])

it's easy to fix via adding special case in `upcast-to-HSequential` in patch, but this maybe not very general, I also think even `upcast-to-HSequential` isn't general at all.

How should I solve this error?



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 31/Mar/14 6:01 AM ]

You should call subtype directly with those two types and add printlns until the culprit is obvious.

There's a nice sub? macro in c.c.t.test.core

There's a bug in your second subtype? case; the test should be (HSequential? s), not (HSequential? t).

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

I believe if you fix the subtype case, the left hand side will have a CountRange that satisfies the right.

Comment by Ambrose Bonnaire-Sergeant [ 31/Mar/14 6:08 AM ]

Hmm I see what you were trying to do. I suggest following HMap's subtyping.

Make `upcast-HSequential` which is [HSequential -> Type]. It always returns a slightly less accurate type, which is still useful to continue the subtyping check.

The subtyping case should test (HSequential? s) and then (subtype (upcast-HSequential s) t).

Comment by Ambrose Bonnaire-Sergeant [ 31/Mar/14 6:12 AM ]

I think upcast-HSequential should do something like

(HSequential [Any])
=>
(I (t/Coll Any) clojure.lang.Sequential (ExactCount 1))

Comment by Ambrose Bonnaire-Sergeant [ 31/Mar/14 6:23 AM ]

A nice thing we can do with HSequential is move most of the custom logic for (subtype HVec HVec), (subtype HList HList) and (subtype HSeq HSeq) into one place.

All we need is {HVec,Hlist,HSeq}->HSequential functions, and then we can have subtyping cases like

(and (HVec? s) (HVec? t))
(subtype (HVec->HSequential s) (HVec->HSequential t))

This also applies to cs_gen.

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

Or, could we add special handler in `In` to handle the case of intersection of HSequential and CountRange, like change (In (HSequential [a b c *]) (CountRange 1 5)) -> (HSequential [a b c c c]) and (In (HSequential [a *]) (CountRange 1)) -> (HSequential [a a *])

something like that?

Comment by Ambrose Bonnaire-Sergeant [ 31/Mar/14 9:08 AM ]

I'm not sure. The first example would actually be (U (HSequential [a b]) (HSequential [a b c]) (HSequential [a b c c]) (HSequential [a b c c c]).

It might generate very large types.

Either way the subtype style I described is still needed.

Comment by Di Xu [ 01/Apr/14 10:55 PM ]

Well, I think we're talking about two different problem here, the problem you're talking about is how to compare HSequential with other type, the one I'm talking about is how to use CountRange to extends HSequential type, because

(HSequential [Any *])

can never be the subtype of

(HSequential [Any Any *])

, only when we put constraint that the count of first one is at least 1. Right?

So, I'll first extends `In` as I described here, and leave your solution to future. For the efficience consideration, I think it's not a big problem, because most CountRange just specified low bound as `empty?`, so we don't need to generate a large set very often.

Comment by Ambrose Bonnaire-Sergeant [ 03/Apr/14 6:36 AM ]

I was responding that (HSequential [a b c *]) (CountRange 1 5)) -> (HSequential [a b c c c])
is unsound, and should be (U (HSequential [a b]) (HSequential [a b c]) (HSequential [a b c c]) (HSequential [a b c c c]).

Comment by Ambrose Bonnaire-Sergeant [ 03/Apr/14 6:43 AM ]

Perhaps a better idea is to add an extra field in HSequential/HList etc. for a CountRange. Then (HSequential [a b c *]) (CountRange 1 5)) -> (HSequential [a b c *] :count (CountRange 1 5))

That way there's no chance of generating massive types, and we can utilise that information in subtyping to simplify the HSequential at the last minute.

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

Wow, that's a good idea. So when (> (:lower c) (count (:types t))) we should extends the types with (repeat (:rest t)), but I don't know what to do with drest. I will mark it unsupport.

There're a problem makes me complete lost. With hsequential-demo.diff patch, after changing the r/-hsequential into r/-hvec there'll be no problem testing

lein test :only clojure.core.typed.test.core/annotate-user-defined-ploydot

but after changing back to r/-hsequential, there'll be a type error. I don't know what I'm missing, I've debugged it for a whole day and still feel lost. I've greped the code that support HVec in fold_default.clj, frees.clj, promote_demote.clj and subst.clj. And copy the code to implement HSequential, but still got type error. I don't know what's going on here.

ps. the bug you mentioned in the first comment is not a bug, I was going to test if t is HSequential or not, and upcast s to HSequential if so, just like the {HVec,Hlist,HSeq}->HSequential you menntioned.

Comment by Ambrose Bonnaire-Sergeant [ 03/Apr/14 1:18 PM ]

I found a bunch of (pre-existing) bugs and added a few cases you were missing. I started getting the same type error for HVec/HSequential; hopefully the attached patch will help you continue.

Comment by Di Xu [ 07/Apr/14 3:02 AM ]

Well, turns out we don't need CountRange to pass the test case, but we also can't pass it with `first`, because both function and arguments have free variable, so change the test case to concrete type.

Comment by Ambrose Bonnaire-Sergeant [ 07/Apr/14 5:07 AM ]

The rest arguments of a function are actually ISeq's, not just Sequentials. We should be calling -hseq instead of -hsequential in the :fn check method.

If you `mvn test` you'll see what this breaks.

Next step:

  • add rest/drest to HSeq (and HList if you're enthusiastic)
  • change -hsequential to -hseq
Comment by Di Xu [ 08/Apr/14 9:06 AM ]

added, but failed in core/mapentry-first-test, core/hvec-ops and core/variable-hvec-test

I think those cases is beyond my current ability, it involve infer type variable in HSequential.

also failed in clojure.core.typed.test.fail.recur-non-seq-rest and clojure.core.typed.test.fail.recur-empty-seq

I don't know why should these cases fail. And confused by check-recur, which requires rest-arg-type has at least one element.

Comment by Ambrose Bonnaire-Sergeant [ 08/Apr/14 9:44 AM ]

Thanks, having a look.

You've added a few subtyping cases that are unsound. I'll fix them in my next patch.

It's important that (subtype? S T) only returns true if we can insert S in all places T is accepted.

(subtype? (HVec [1]) (HSequential [1]))
;=> true

(subtype? (HSequential [1]) (HVec [1]))
;=> false

(subtype? (HList [1] (HSeq [1]))
;=> true

(subtype? (HSeq [1]) (HList [1]))
;=> false

Comment by Ambrose Bonnaire-Sergeant [ 08/Apr/14 10:39 AM ]

Added ambrose-hsequential-v3-1.patch

Should pass all the tests. Please try it out.

Comment by Di Xu [ 09/Apr/14 2:27 AM ]

Oh, right.. it's unsound to do that in subtype, I was foolish that moment, sorry.

It's seems that you solved (first [1 'a]) by

(and (r/RClass? S)
     ((some-fn r/HeterogeneousVector? r/HSequential?) T))
         (if-let [[Sv] (seq
                         (filter (some-fn r/HeterogeneousVector? r/HSequential?)
                                 (map c/fully-resolve-type (c/RClass-supers* S))))]

right?

Well, I think we could close this ticket now. It spend such long time

Comment by Ambrose Bonnaire-Sergeant [ 09/Apr/14 2:40 AM ]

Actually I believe I added some extra cases for (cs-gen HVec HSeq) to fix (first [1 'a]).

That particular addition fixed (cf (-> {:a 1} first second) Number), because AMapEntry has a HVec ancestor and we used to rely on `second` having a HVec arity. Now `second` has a HSequential arity, we want to trigger this case if there's a (cs-gen RClass HSequential), instead of just (cs-gen RClass HVec).

Fantastic work, I'll merge this soon.

Comment by Ambrose Bonnaire-Sergeant [ 10/Apr/14 10:47 AM ]

Merged.





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

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

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

core.typed 0.2.40



 Description   

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

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

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

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

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






[CTYP-128] Trim down the AOT jar Created: 28/Mar/14  Updated: 20/Jul/14  Resolved: 20/Jul/14

Status: Resolved
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: Declined Votes: 0
Labels: None


 Description   

Started some work here https://github.com/clojure/core.typed/commit/d5c1d23f15301100e36f0290df43ad09e4b377d1

All tests started failing.



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

Clojure doesn't make this easy by any means.





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

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

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


 Description   

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

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

Type Error (...) Type mismatch:

Expected: 	java.lang.Number

Actual: 	Any
in: (:foo x)

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

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

Both HMap and record bounds exhibit the same problem.



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

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





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

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

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

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

 Description   

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



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

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

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

Return something like:

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

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

Great work!

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

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

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

I think

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

is not accurate enough, my patch generate type like

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

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

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

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

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

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

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

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

So we need to:

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

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

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

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

A few things before I merge:

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

done, but assume you mean

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

by

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

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

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

done

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

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





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

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

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


 Description   

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

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



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

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

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

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

Thank you!





[CTYP-124] case should utilize negative information Created: 21/Mar/14  Updated: 23/Mar/14

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

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


 Description   

Per discussion on IRC, here's the refheap of the test case: https://www.refheap.com/62684



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

Not as simple as I thought due to `case` scoping a fresh local.

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





[CTYP-123] Using clojure.core.typed.async requires calling typed-deps Created: 16/Mar/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: Gary Fredericks Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

0.2.38-20140315.151412-2



 Description   

The following code will only type check if (t/typed-deps clojure.core.typed.async) is added below the ns form:

(ns controller.tmp
  (:require [clojure.core.async :as a]
            [clojure.core.typed :as t]
            [clojure.core.typed.async :as t.a]))

(t/ann my-chan [-> (t.a/Chan Number)])
(defn my-chan [] (t.a/chan> Number))

;; (t/check-ns):
;;
;; WARNING: Type Checker: Definition missing: clojure.core.async/chan
;; Hint: Use :no-check metadata with ann if this is an unchecked var
;; Checked 1 namespaces (approx. 18 lines) in 7241.543591 msecs
;; Type Error (controller/tmp.clj:18:18) Unannotated var clojure.core.async/chan
;; Hint: Add the annotation for clojure.core.async/chan via check-ns or cf
;; in: clojure.core.async/chan
;;
;;
;; Type Error (controller/tmp.clj:18:18) Cannot instantiate non-polymorphic type: Error
;; in: clojure.core.async/chan
;;
;;
;; ExceptionInfo Type Checker: Found 2 errors  
;; clojure.core/ex-info (core.clj:4403)


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

Fixed sometime before 0.2.58





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

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

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

Mac OS X, clojure 1.5.1, Oracle JDK 1.7.0_45



 Description   

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

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

This is the result of check-ns:

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

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



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

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

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

Fixed in 0.2.38-20140316.133526-3





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

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

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


 Description   

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

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

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

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


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

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

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

Awesome, thanks Ambrose





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

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

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

core.typed 0.2.36



 Description   

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

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

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

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


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

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

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

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





[CTYP-119] Record/datatypes should update like HMaps via occurrence typing Created: 13/Mar/14  Updated: 13/Mar/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





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

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

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

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

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

annotate cast using add-invoke-special-method

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

The invoke-special case should be more lenient.

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

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

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

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

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

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

I mean this is still type correct:

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

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

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

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

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

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

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

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

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

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

To make an intersection, use c/In.

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

Make a failing test like this:

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

Please add a few failing tests.

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

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

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

Ah yes.

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

added

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

Merged.

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

Thanks!

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

got it.





[CTYP-117] Getting deprecated warning with fn> Created: 12/Mar/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: Task Priority: Trivial
Reporter: Brian Zwahr Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Via instructions from Twitter, I'm creating this ticket. When running lein typed check against a function using fn>, I'm getting a deprecated warning message. You can see the code and message here:

https://gist.github.com/echosa/9508942



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 01/May/14 2:17 PM ]

That syntax is deprecated, wherever you copied that style of nested vectors in fn> should be updated. Do you remember which docs suggested that syntax?

Comment by Brian Zwahr [ 04/May/14 12:34 PM ]

I do not remember. I've been looking through to try and find it again, but I can seem to. There's a chance this was homegrown code that I wrote incorrectly due to my (continuing) lack of understanding of typed Clojure. Was this deprecated even a couple months ago when I was trying it?

So, what would be the proper way to do this?

I'll continue looking for any references to this type of code and will report them if I find them.

Comment by Ambrose Bonnaire-Sergeant [ 04/May/14 10:51 PM ]

You don't need vectors around each parameter annotation.





[CTYP-116] Apply doesn't work with dotted arguments Created: 11/Mar/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: Gary Fredericks Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

Attachments: File apply.diff    

 Description   

This code:

(t/ann foo (All [x y ...] [[y ... y -> x] -> [y ... y -> x]]))
(defn foo
  "Doesn't do anything useful."
  [f]
  (let [mem (memoize (fn [& args] #(apply f args)))]
    (fn [& args]
      ((apply mem args)))))

On type-check throws this exception:

AssertionError Assert failed: (not (some :drest (:types fin)))  clojure.core.typed.check/relevant-Fns (check.clj:2661)

I'm using core.typed version 0.2.36.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 11/Mar/14 10:31 PM ]

I suspect minimal case is:

(cf (fn [f & args] (apply f args)) (All [b ...] [[b ... b -> Any] b ... b -> Any]))
Comment by Gary Fredericks [ 11/Mar/14 10:35 PM ]

Indeed I get the same error with that snippet.

Comment by Di Xu [ 18/Apr/14 9:25 PM ]

seems solved this problem

Comment by Ambrose Bonnaire-Sergeant [ 01/May/14 2:15 PM ]

Need to look at this closer, but it seems line 63 completely ignores rest/drest types.

Comment by Di Xu [ 04/May/14 2:34 AM ]

Oops, that's an error. I added to see how it works, forget to delete it.

The main problem with this patch is it assume user invoke apply with argument that just like declared function type, for example:

(t/ann foo (All [x ...] [Number String x ... x -> bar]))

and invoke with

(apply foo 1 "bar" local-variable)

not

(apply foo 1 local-variable-with-string-in-first)

but I assume this should be the typical usage of apply, no?

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

This now has a readable error actually relevant to the problem, as of 0.2.58





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

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

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

Attachments: File annotation-v3.diff    
Patch: Code

 Description   

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



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

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

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

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

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

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

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

I think it should be:

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

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

Ah, I forget about polymorphic function, sorry.

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

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





[CTYP-114] Should blame correct line number if alias introduces a type error Created: 06/Mar/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   
(def-alias Foo
  '{:a (atom Number)}) ;; this resolves to clojure.core/atom, which doesn't trigger a type error yet

(t/ann f [-> Foo])
(defn f [a]
  a)  ; we get the type error here, blaming `f`.


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

Fixed sometime before 0.2.58





[CTYP-113] Better documentation for override-method Created: 04/Mar/14  Updated: 04/Mar/14

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

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





[CTYP-112] Better error for type mismatch with loop/recur Created: 04/Mar/14  Updated: 04/Mar/14

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

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


 Description   

Currently a type error (especially involving locals) that complains about a mismatch to a recur statement could be more descriptive. Perhaps mention where the corresponding loop> is? Should also mention the recur statement.

(loop> [f :- AnyInteger]
(let [n (ann-form 1.2 (U Number nil))]
(recur n)))

Type Error (clojure/math/numeric_tower.clj:89:10) Local binding n530 expected type AnyInteger, but actual type (U Number nil)
in: n530






[CTYP-111] Clearer error message for misusing special type Created: 27/Feb/14  Updated: 27/Feb/14

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

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


 Description   

Using HMap and Fn outside of the first argument of a paren could give a clearer hint.






[CTYP-110] Add satisfies? Created: 27/Feb/14  Updated: 27/Feb/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 support satisfies?. Needs to be hard-coded like instance?.






[CTYP-109] Better error message for TFn app Created: 27/Feb/14  Updated: 27/Feb/14

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

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


 Description   

Currently applying a no-TFn type as an operator to TApp gets this error:

"Type Error (pallet/utils.clj:378:22) First argument to TApp must be TFn, actual: Symbol" mean?
ambrosebs
it's found a type like (Symbol ...)

https://www.refheap.com/48221

Should be clearer.






[CTYP-108] core.typed runs forever Created: 20/Feb/14  Updated: 20/Feb/14

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

Type: Defect Priority: Blocker
Reporter: Cees van Kemenade Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File infinite2.clj    

 Description   

The core.typed checkers runs forever on my files. I've added markers to pinpoint the problem (unchecked functions are mentioned on the standard-output). Thus I was able to prune my failing file to a fairly minimal test-case that runs forever.

I would be nice if (check-ns) had an option to output logging/information for each function that is checked. As this would save significant time in pin-pointing where core.typed stagnates.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Feb/14 11:10 AM ]

Thanks for the report. Hangs for me too.

core.typed logs each line it's checking if you call check-ns like this:

(check-ns ns :trace true)

Comment by Ambrose Bonnaire-Sergeant [ 20/Feb/14 11:16 AM ]

This is the minimum case: https://gist.github.com/frenchy64/9118729

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





[CTYP-107] automatic pre- and post-conditions for unchecked code Created: 19/Feb/14  Updated: 20/Jul/14  Resolved: 27/Feb/14

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

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


 Description   

Currently it is fairly difficult to use core.typed to achieve/ensure production quality code. Often it happens that part of your own code does not pass the core.typed checker. Of course you can add the :no-check to your function, but in that case all type-checking is bypassed for this function and it can inject arbitrary data into the rest of your program (the type-signature is not enforced anymore.

It would be possible to prevent this issue if core.typed offered the opportunity to derive pre- and post-conditions based on the type-signature. This way unchecked code would use run-time checking as a fall-back scenario to prevent unchecked code could inject arbitrary data into the rest of your program (like the schema-library by prismatic, but using the core.typed annotations instead of schemas).
One step beyond would be to:
1. Use dynalint for the unchecked code (if this is possible)
2. Generate wrappers with pre- and post-conditions for external libaries.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 19/Feb/14 7:08 AM ]

This is highly desirable. Typed Racket does an excellent job, so it's simple enough to follow their lead.

The biggest issue is actually the time it takes to load the type checker. I don't want to impose this on anyone who isn't generating contracts from types.

I've pondered writing a simpler intermediate AST representation of types that requires no further loading of the type system. It would look very much like the output of tools.analyzer or CLJS analysis. When a global annotation is added, it would be converted to an AST (very cheaply). Converting this AST to a contract would be less robust than using the type manipulating utilities of the full type checker, but the idea is that a type contract might generate incorrectly, but a "check-ns" always tells you after the fact.

It sucks, but some people rely on the zero load-time of core.typed (it's a pretty sweet property too!).

In short, I've thought a lot about this, and it's a glaring missing component in a gradual type system.

Comment by Cees van Kemenade [ 19/Feb/14 1:37 PM ]

I can imagine the dilemma. Core-typed has zero slow-down as all checking is taken off-line. I can image that the launch of the type-system at runtime is a significant overhead. To prevent this overhead the preparations of the type-checking should be brought to compile-time. Your suggestion of generating AST representations does this.

I was considering generation of source-code at compile time to generate ordinary pre- and post-conditions, or to wrap a function symbol with some checks. However, it seemed to be less than trivial to locate where the ann-macro store the type-annotations. I suppose the limited documention on this type of internal.

I guess the manual insertion of clojure pre- and post-conditions on unchecked functionscurrently is the best way out for the time being.

Comment by Ambrose Bonnaire-Sergeant [ 27/Feb/14 8:46 AM ]

Added clojure.core.typed/pred in 0.2.34. This is about as good as it's going to get for now.

Comment by Cees van Kemenade [ 28/Feb/14 2:31 AM ]

Thanks, this is a great tool to implement a postcondition for a function that has a ^:no-check directive. This way you can prevent that unchecked functions insert incorrect data into your process-flow.
Cool!

Comment by Cees van Kemenade [ 04/Mar/14 2:58 PM ]

Note:
When using this I noticed that (core.typed/pred T) returns an internal error when your type is (Seqable X) or your type contains a (Seqable X) somewhere at a nested level.

However, doing the transformation (Seqable X) --> (core.typed/Coll X)
works nicely.





[CTYP-106] Else branch does not tighten scope to non-sequential Created: 19/Feb/14  Updated: 20/Jul/14  Resolved: 20/Jul/14

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

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

Attachments: File failDerive1a.clj     File failDerive1.clj    

 Description   

This error is related to the example longOptions.clj of CTYPE-102 and the derived hmap/big-options mentioned as CTYPE-99. I've prepared a new example to clearly show the issue.

The first function passes type-checking. However, it contains a redundant check on line 83 and a redundant base-case on line 85.

The second function does not pass the (check-ns) as it assumes that notifs can be a (seqable String). However, as this is the else-branch of line 112 (if (or (sequential? notifs) (seq? notifs) (vector notifs)) ... so the notifs can not be a (Seqable String) in this branch.

NOTE: core.typed does not know clojure.core/sequential? yet. Therefore the seq? and vector? tests are added too.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 19/Feb/14 5:03 AM ]

Seqable doesn't extend Sequential, ISeq or IPersistentVector, so it's expected that this fails.

I suspect that the type for :st_notif is always an immutable clojure collection? If so, annotate :st_notif as (U (t/Coll String) String nil), and use (coll? notifs) as the predicate. Otherwise, try (not (string? notifs)) as the predicate.

Comment by Cees van Kemenade [ 19/Feb/14 2:18 PM ]

I tried to turn it into clojure.core.typed/Coll and that worked fine.
Thanks for the suggestion/solution!

Out of curiosity I tried as an alternative to check for (= (class notifs) clojure.lang.Seqable) as a second solution, but that did not solve the issue.
So I will stick to solution 1.

Comment by Ambrose Bonnaire-Sergeant [ 19/Feb/14 7:21 PM ]

= isn't useful for narrowing types, especially in the else branch. instance? and isa? would be more useful.

Comment by Cees van Kemenade [ 20/Feb/14 9:48 AM ]

Sorry, it was a typo from my side. I used (isa? ....) see line 166 of the attached fail failDerive1a.clj
This code triggers a type-error on line 171.

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

I think this is resolved.





[CTYP-105] derive/subtype failure on hashmap Created: 19/Feb/14  Updated: 19/Feb/14  Resolved: 19/Feb/14

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

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

linux/java + core.typed 0.2.31


Attachments: File failDerive2.clj    

 Description   

The attached code fails when checking the namespace, as core.typed incorrectly assumes that the return-type is incorrect. Part of error-output is included as string ErrInfo and compared for difference with the return-type from the proto-type of the failing function.

When you load the file the analysis of the error-message is shown (run check-ns to see the message)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 19/Feb/14 3:00 AM ]

Fixed in 0.2.32: https://github.com/clojure/core.typed/commit/0e0a41c917ef027bf47ab6ed90955881975a7a13

Comment by Cees van Kemenade [ 19/Feb/14 12:16 PM ]

Great!

Thanks for the rapid fix.
Tested it it and it works fine.

C.





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

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

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


 Description   

Should be similar to the vim and emacs plugins.

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

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

2 refactorings should be included:

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

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

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

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

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



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

I'll tackle this problem this week





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

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

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


 Description   

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

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

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

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






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

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

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

core.typed 0.2.25


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

 Description   

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

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

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

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

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



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

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

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

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

Hi Cees,

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





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

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

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


 Description   

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

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

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


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

Confirmed.

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

Fix will be included in 0.2.22.

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





[CTYP-100] RClass ancestors should work with reset-env Created: 09/Dec/13  Updated: 09/Dec/13

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

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





[CTYP-99] Checking an ns becomes significantly slower as the number of optional keys in a HMap increases Created: 03/Dec/13  Updated: 14/Feb/14  Resolved: 14/Feb/14

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

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

Attachments: File core.clj     File core.clj     File project.clj     GZip Archive test-hmap.tar.gz    

 Description   

I'm using clojure.core.typed 0.2.19 with the slim classifier but I've observed the same without slim.

My suspicion is that the latent filters associated with functions grow in size exponentially with each extra optional key to a HMap (based on the output when you have a type error). I think it's generating all combinations of present and absent keys for the HMap when calculating latent filters for a function.

I've attached a tarball with a lein project with ten namespaces that all contain the same ten simple functions in the form

(t/ann f [(HMap :optional {:a String}) -> (t/Option String)])
(defn f [m]
  (:a m))

The type annotations vary in the number of optional keywords.

(test-hmap.core/go) checks all the namespaces. The time to check each namespace grows non-linearly. The first namespace gets penalised by core.typed initialisation the first time it's run.

E.g. on my local machine:

test-hmap.one
Start collecting test-hmap.one
Finished collecting test-hmap.one
Collected 1 namespaces in 20.743 msecs
Start checking test-hmap.one
Checked test-hmap.one in 46.231 msecs
Checked 1 namespaces (approx. 34 lines) in 67.672 msecs


test-hmap.two
Start collecting test-hmap.two
Finished collecting test-hmap.two
Collected 1 namespaces in 18.751 msecs
Start checking test-hmap.two
Checked test-hmap.two in 45.525 msecs
Checked 1 namespaces (approx. 35 lines) in 64.814 msecs


test-hmap.three
Start collecting test-hmap.three
Finished collecting test-hmap.three
Collected 1 namespaces in 19.106 msecs
Start checking test-hmap.three
Checked test-hmap.three in 57.346 msecs
Checked 1 namespaces (approx. 35 lines) in 77.055 msecs


test-hmap.four
Start collecting test-hmap.four
Finished collecting test-hmap.four
Collected 1 namespaces in 21.222 msecs
Start checking test-hmap.four
Checked test-hmap.four in 51.339 msecs
Checked 1 namespaces (approx. 35 lines) in 73.155 msecs


test-hmap.five
Start collecting test-hmap.five
Finished collecting test-hmap.five
Collected 1 namespaces in 22.215 msecs
Start checking test-hmap.five
Checked test-hmap.five in 63.415 msecs
Checked 1 namespaces (approx. 35 lines) in 86.309 msecs


test-hmap.six
Start collecting test-hmap.six
Finished collecting test-hmap.six
Collected 1 namespaces in 23.76 msecs
Start checking test-hmap.six
Checked test-hmap.six in 99.407 msecs
Checked 1 namespaces (approx. 35 lines) in 123.881 msecs


test-hmap.seven
Start collecting test-hmap.seven
Finished collecting test-hmap.seven
Collected 1 namespaces in 26.519 msecs
Start checking test-hmap.seven
Checked test-hmap.seven in 213.515 msecs
Checked 1 namespaces (approx. 35 lines) in 240.639 msecs


test-hmap.eight
Start collecting test-hmap.eight
Finished collecting test-hmap.eight
Collected 1 namespaces in 32.581 msecs
Start checking test-hmap.eight
Checked test-hmap.eight in 626.76 msecs
Checked 1 namespaces (approx. 35 lines) in 659.975 msecs


test-hmap.nine
Start collecting test-hmap.nine
Finished collecting test-hmap.nine
Collected 1 namespaces in 43.478 msecs
Start checking test-hmap.nine
Checked test-hmap.nine in 2634.468 msecs
Checked 1 namespaces (approx. 35 lines) in 2678.716 msecs


test-hmap.ten
Start collecting test-hmap.ten
Finished collecting test-hmap.ten
Collected 1 namespaces in 84.394 msecs
Start checking test-hmap.ten
Checked test-hmap.ten in 9277.54 msecs
Checked 1 namespaces (approx. 35 lines) in 9362.613 msecs


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 03/Dec/13 12:50 PM ]

Yes, the primitives are :mandatory, :absent-keys and :complete; :optional expands to be in terms of those.

Thanks for the report, I haven't done performance testing on this strategy. It will probably need to be reconsidered.

Comment by Cees van Kemenade [ 26/Jan/14 1:04 PM ]

code of project ctcrash

Comment by Cees van Kemenade [ 26/Jan/14 1:05 PM ]

+1 For this issue.

I've spend quite some time to learn core.typed on a real use case, and I have to say that I'm amazed by the power of the analysis and the potential to prevent errors that otherwise would be detected to late! Apart from that the type-annotations are valuable and precise information about the interface when doing maintenance at code you did not see for some time.
Two big reasons to use core.typed, however, as I turned more and more code into typed code the number of optional keys increased in my core data-record increase, and core.typed (check-ns) slowed down to the extreme (using version 0.2.25 (current stable)). I refactored the code to get a single line of code that triggers the issue on my core data structure a (Seqable DbMsg). Attached you find the project.clj and code (core.clj vs 8:09pm).

When I reduce the number of optional keys to 4-5 the (check-ns) runs in a few seconds. But having 9-11 optional keys kills the (check-ns) process.

I hope this one-liner helps making the issues easy to reproduce.
Currently I don't know a work-around for this issue,
so I can not use core.typed to check my project.

I guess that many people/projects should run into the same issues,
as the pattern is returning quite often in clojure:

1. start with data-set with small Hashmaps
2. the hashmaps evolve in a number steps (meaning more keys are added and some of the existing keys are removed)
I guess the workaround would be to use limited or no optional keys, and prepare a custom HMap definition for each stage of analysis. Although this would work, the amount of bookkeeping already significant for a all records are running through the same stages (linear process), and will be a showstopper if it is a non-linear process (not all records follow the same path (sequence of analysis stages)).
I will investigate whether splitting in multiple types (for different stages) will rescue my day.

Comment by Ambrose Bonnaire-Sergeant [ 26/Jan/14 7:51 PM ]

Upgraded to 'Blocker'.

Comment by Ambrose Bonnaire-Sergeant [ 27/Jan/14 6:34 AM ]

This is theoretically trivial to implement, and just involves shuffling around where optional keys are handled. However, this is spread out all over the code base, so I may not complete the patch for a week.

Great to hear core.typed is working out for you!

Comment by Cees van Kemenade [ 27/Jan/14 6:44 AM ]

Thanks for picking up this issue fast.
I'll wait patiently.

Comment by Ambrose Bonnaire-Sergeant [ 14/Feb/14 2:26 AM ]

This is fixed in 0.2.31.

I've added both of your tests in the test suite - thanks! https://github.com/typedclojure/core.typed-test-suite/tree/master/src/hmap

Please confirm and I'll close the issue.

Comment by Cees van Kemenade [ 14/Feb/14 4:11 AM ]

This resolve the issue and also resolves CT-102.
Thanks!

The code in hmap/big-options.clj (from your test-suite) still contains a workaround to make core.typed proceed without errors.
The (if (string? notifs) ... on line 107 is introduced to prevent a type-error (core.typed infers it that notifs might als be a (sequable String). However, as this is the else-branch of line 104 (if (or (seq? notifs) (vector notifs)) ... the case that notifs is a (Seqable string) can be excluded already).
Also using on line 104 the more general (if (sequential? notifs) ... does not resolve this issues.

Is this inference error already on the list, or would you recommend posting a seperate JIRA-case for this issue?

Comment by Gordon Syme [ 14/Feb/14 5:56 AM ]

Our core.typed checks run an order of magnitude quicker now (~400s --> ~80s). And they keep that speed with all the extra optionals now. That's really awesome, thanks Ambrose!





[CTYP-98] Implement a defrecord> macro Created: 23/Nov/13  Updated: 03/Dec/13

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

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

Attachments: File defrecord    

 Description   

In the interests of rendering c.c.t code more concise, implement a defrecord> macro wraping defrecord and ann-record.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 03/Dec/13 12:57 PM ]

There is another case I would like to consider: specifying polymorphic ancestors. Currently ann-datatype/ann-record take an undocumented keyword argument :unchecked-ancestors.

eg.

(ann-protocol [[x :variance :invariant]] Foo
  -foo
  [(Foo x) -> x])
(defprotocol> Foo
  (-foo [this]))

(ann-datatype DTFoo [m :- Any]
  :unchecked-ancestors [(Foo String)])
(deftype DTFoo [m]
  ; this next line might read (Foo String), instead of :unchecked-ancestors entry
  Foo
  (-foo [this] "a"))

I will revisit this issue once I've ironed out how :unchecked-ancestors should work.





[CTYP-97] 0.2.16 seems to introduce a bug Created: 14/Nov/13  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: kshramt Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

core.typed 0.2.16 and later



 Description   

Some changes introduced by core.typed-0.2.16 seems to cause `Type Error (sicp.err:49:13) Cannot resolve type: a` for following code.

0.2.15: :ok
0.2.16: error
0.2.17: error
0.2.18: error
0.2.19: error

$ lein typed check sicp.err
Initializing core.typed ...
Loading Clojurescript...
Clojurescript not found
"Elapsed time: 3130.848 msecs"
core.typed initialized.
Start collecting sicp.err
Finished collecting sicp.err
Collected 1 namespaces in 3293.048 msecs
Start checking sicp.err
Type Error (sicp.err:49:13) Cannot resolve type: a
Hint: Is a in scope?
Hint: Has a's annotation been found via check-ns, cf or typed-deps?
Found errors
Subprocess failed
(ns sicp.err
  (:require [clojure.test :refer [is are]]
            [clojure.core.typed :refer [ann fn>
                                        Seqable] :as typed])
  (:import (clojure.lang ASeq LazySeq)))


(ann reduce_ (All [a b] (Fn [[a b
                              -> b]
                             b
                             (Seqable a)
                             -> b]
                            [[a (Seqable (U a b))
                              -> (Seqable (U a b))]
                             (Seqable (U a b))
                             (Seqable a)
                             -> (Seqable (U a b))])))
(defn reduce_
  {:test #(do (is (= (reduce_ +' 0 [1 2]) 3))
              (is (= (reduce_ / 1 [2 3]) 2/3)))}
  [f zero coll]
  (if-let [s (seq coll)]
    (f (first s)
       (reduce_ f zero (rest s)))
    zero))

(ann append_ (All [a b] [(Seqable a) (Seqable b) -> (U (Seqable (U a b))
                                                       (ASeq (U a b)))]))
(defn append_
  [coll1 coll2]
  (reduce_ cons coll2 coll1))


; -------- main

; if you comment out this function, you will get :ok
(ann map-1 (All [a b] [[a -> b] (Seqable a)
                       -> (LazySeq b)]))
(defn map-1 [f coll]
  (lazy-seq
   (if-let [s (seq coll)]
     (cons (f (first s))
           (map-1 f (rest s))))))

(ann map-2 (All [a b] [[a -> b] (Seqable a) -> (LazySeq b)]))
(defn map-2
  [f coll]
  (lazy-seq
   (reduce_ (fn> [x :- a ; ERROR!! -- Cannot resolve type: a
                  y :- (Seqable b)]
              (append_ [(f x)] y))
            []
            coll)))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 14/Nov/13 7:58 PM ]

Ah, that's not surprising. I overhauled the scoping for type variables, forgot this case.

Thanks for the report.

Comment by vladimir [ 18/Mar/14 12:55 PM ]

Hello,

still got the same on 0.2.38.. is it closed because fixed?

Regards,

Vladimir

Comment by Ambrose Bonnaire-Sergeant [ 18/Mar/14 1:18 PM ]

Added passing test for CTYP-97 https://github.com/clojure/core.typed/commit/614244afc482826b650e0ebd14892f0ebbc411a0

Comment by Ambrose Bonnaire-Sergeant [ 18/Mar/14 1:19 PM ]

Vladimir,

Please elaborate on your issue.

Thanks
Ambrose





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

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

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

Clojure 1.5.1


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

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

As opposed to the current LazySeq return type.

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



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

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

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

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

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

Using Seq as return types.





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

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

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

core.typed 0.2.19



 Description   

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



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

Yes, I think you're right. Thanks.

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

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





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

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

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


 Description   

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



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

Fixed in 0.2.19

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





[CTYP-93] Support refinement types Created: 08/Nov/13  Updated: 08/Nov/13

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   

Typed Racket's refinement types are useful. We should implement something similar.






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

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

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

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

 Description   

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



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

Merged, included in 0.2.17.





[CTYP-91] polymorphic ann-protocol doesn't work Created: 30/Oct/13  Updated: 05/Nov/13  Resolved: 05/Nov/13

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

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

Clojure 1.5.1, Core.typed 0.2.14 and 0.2.15



 Description   

The example of a polymorphic defprotocol annotation from the documentation is:

(ann-protocol [[x :variance :covariant]]
  IFoo
  bar
  [IFoo -> Any]
  baz
  [IFoo -> Number])

It's implied that there exists a corresponding protocol like this:

(defprotocol> IFoo
  (bar [this])
  (baz [this]))

Type checking this code with check-ns gives an error:

AssertionError Assert failed: ((u/hash-c? (every-pred symbol? (complement namespace)) Type?) methods)
	clojure.core.typed.type-rep/Protocol-maker (type_rep.clj:289)
	clojure.core.typed.type-ctors/Protocol* (type_ctors.clj:448)
	clojure.core.typed.collect-phase/gen-protocol* (collect_phase.clj:443)
	clojure.core.typed.collect-phase/fn--14235 (collect_phase.clj:458)
	clojure.lang.MultiFn.invoke (MultiFn.java:227)
	clojure.core.typed.collect-phase/collect -COLON-invoke14011 (collect_phase.clj:189)
	clojure.lang.MultiFn.invoke (MultiFn.java:227)
	clojure.core.typed.collect-phase/collect-asts (collect_phase.clj:119)
	clojure.core.typed.collect-phase/collect-ns (collect_phase.clj:107)
	clojure.core.typed/check-ns (typed.clj:1459)
	clojure.core.typed/check-ns (typed.clj:1429)

Incidentally, it would be nice if the example in the documentation actually used the declared type parameter in some way.



 Comments   
Comment by Russell Mull [ 30/Oct/13 10:01 PM ]

The above stack trace is from 0.2.14. This is the trace for 0.2.15:

AssertionError Assert failed: ((u/hash-c? (every-pred symbol? (complement namespace)) Type?) methods)
	clojure.core.typed.type-rep/Protocol-maker (type_rep.clj:289)
	clojure.core.typed.type-ctors/Protocol* (type_ctors.clj:448)
	clojure.core.typed.collect-phase/gen-protocol* (collect_phase.clj:443)
	clojure.core.typed.collect-phase/fn--14237 (collect_phase.clj:458)
	clojure.lang.MultiFn.invoke (MultiFn.java:227)
	clojure.core.typed.collect-phase/collect -COLON-invoke14013 (collect_phase.clj:189)
	clojure.lang.MultiFn.invoke (MultiFn.java:227)
	clojure.core.typed.collect-phase/collect-asts (collect_phase.clj:119)
	clojure.core.typed.collect-phase/collect-ns (collect_phase.clj:107)
	clojure.core.typed/check-ns (typed.clj:1459)
	clojure.core.typed/check-ns (typed.clj:1429)
Comment by Ambrose Bonnaire-Sergeant [ 05/Nov/13 9:52 AM ]

This exposes that polymorphic protocols are completely untested :/

This issue is fixed in 0.2.16: https://github.com/clojure/core.typed/commit/4474f76eea1e966523914c5455761f1e7b8542c8

Also updated the doc: https://github.com/clojure/core.typed/commit/216454c8c292d68dfa1ac1cd5ce36e00f43cc1c8

This doesn't mean polymorphic protocols/datatypes are usable yet, but it's progress. Working on it.





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

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

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


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

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





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

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

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


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

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





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

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

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

clojure 1.5.1
core.typed 0.2.13



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

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

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






[CTYP-87] Handle variace in datatype cgen Created: 15/Oct/13  Updated: 15/Oct/13

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

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


 Description   

https://github.com/clojure/core.typed/blob/master/src/main/clojure/clojure/core/typed/cs_gen.clj#L739






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

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

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


 Description   

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



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

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





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

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

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


 Description   

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



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

The following minimal example causes this error for me:

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

Whereas the following doesn't:

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

Thanks Greg, made fixing this easy.

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





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

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

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


 Description   

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



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

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





[CTYP-83] check-ns takes exponentially longer on each invocation Created: 04/Oct/13  Updated: 15/Feb/14

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

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


 Description   

Running `(check-ns pathological)` repeatedly on the following namespace, `check-ns` takes longer and longer to complete.

(ns pathological
  (:require
   [clojure.core.typed :refer [ann def-alias loop>
                               NonEmptyVec NilableNonEmptySeq]]))

(def-alias VersionVector (NonEmptyVec Number))
(ann version-less [(U nil VersionVector) (U nil VersionVector) -> boolean])
(defn version-less
  "Compare two version vectors."
  [v1 v2]
  (loop> [v1 :- (NilableNonEmptySeq Number) (seq v1)
          v2 :- (NilableNonEmptySeq Number) (seq v2)]
    (let [fv1 (first v1)
          fv2 (first v2)]
      (cond
       (and (not v1) (not v2)) false
       (and v1 (not v2)) false
       (or (and (not v1) v2)
           (and fv1 fv2 (< fv1 fv2))) true
           (and fv1 fv2 (> fv1 fv2)) false
           :else (recur (next v1) (next v2))))))





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

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

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

clojure.core.typed 0.2.13



 Description   

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

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

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

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

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

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

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



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

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





[CTYP-81] clojure.core.async/alts!! fails to check when used with any keyword arguments Created: 03/Oct/13  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: Michael Hanson Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None
Environment:

clojure.core.typed 0.2.13



 Description   

Using alts!! as (alts!! [(chan) (chan)] :priority true) or (alts!! [(chan) (chan)] :priority true :default nil) fails to check, stating that an uneven number of keyword arguments were provided to the function. Removing the keyword arguments checks :ok.

See https://gist.github.com/mybuddymichael/f584ab905a4165f273e6 for the simple test case and repl output.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 11:02 PM ]

Fixed https://github.com/clojure/core.typed/commit/3ab1c12b8e4617a1a65683bb539afcc70793f299





[CTYP-80] Issue with filter subtyping/simplification Created: 02/Oct/13  Updated: 02/Oct/13

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

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


 Description   

I think I broke this with the 0.2.11 changes to union.

http://paste2.org/kWVNZxC7






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

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

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


 Description   

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



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

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





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

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

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


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

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

`(check-ns 'finally)` results in

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


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

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





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

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

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

project.clj:

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



 Description   

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

Code to reproduce:

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

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

Repl:

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

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


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

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

Code:

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

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

Repl:

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

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

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

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

with expected type:
	java.lang.Number

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


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

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

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

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





[CTYP-76] Support KwArgsSeq in apply Created: 01/Oct/13  Updated: 01/Oct/13

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

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


 Description   

Applying keyword arguments doesn't work properly at the moment.

To reproduce:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(cf (ann fn2 [(HMap :mandatory {}) & {} -> '[] ]))
(cf (defn fn2 [m & args]
      []))

(cf (ann fn1 [(HMap :mandatory {}) & {} -> Boolean ]))
(cf (defn fn1 [m & args]
      (empty? (apply fn2 (cons m args)))))

;;This is how it's used:
 (fn1 {} :a string? :b keyword? :c another-boolean-fn?)

;; And this is the type error:

;; Type Error (bouncer.core:2:28) Polymorphic function clojure.core/cons could not be applied to arguments:
;; Polymorphic Variables:
;;   x

;; Domains:
;; 	x (Option (clojure.lang.Seqable x))

;; Arguments:
;; 	(HMap :mandatory {}) (KwArgsSeq)

;; Ranges:
;; 	(clojure.lang.ASeq x)

;; in: (clojure.core/cons m args)

;; in: (clojure.core/empty? (clojure.core/apply bouncer.core/fn2 (clojure.core/cons m args)))

;;  [2 times]
;;  [2 times]
;; Type Error (bouncer.core:2:17) Bad arguments to apply: 

;; Target: 	(Fn [(HMap :mandatory {}) & {} -> []])

;; Arguments:	Error

;; in: (clojure.core/empty? (clojure.core/apply bouncer.core/fn2 (clojure.core/cons m args)))

;;  [2 times]
;;  [2 times]
;; ExceptionInfo Type Checker: Found 2 errors  clojure.core/ex-info (core.clj:4327)

;; Mark set





[CTYP-75] More accurate Long arithmetic Created: 30/Sep/13  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: Major
Reporter: Chris Spencer Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File better-arithmetic.patch     Text File long-arithmetic.patch    

 Description   

The basic operations +*- do not autopromote, so it's safe to assume that an operation on Longs will remain a Long (or throw an exception)



 Comments   
Comment by Chris Spencer [ 30/Sep/13 3:55 AM ]

Attached better-arithmetic which supersedes the other patch. Adds better type preservation/inference for Longs and Doubles through arithmetic.

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

Most ops now have Long/Double arities https://github.com/clojure/core.typed/blob/master/module-check/src/main/clojure/clojure/core/typed/base_env.clj#L1074





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

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

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


 Description   

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

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

an assert is raised with no location information:

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


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

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





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

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

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


 Description   

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

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

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

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

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



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

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

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

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





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

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

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


 Description   

I'm pretty sure this should pass

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

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

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

but it gives

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

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

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

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

with expected type:
moonrise.X

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

Type Checker: Found 1 error






[CTYP-71] Occurrence typing does not deal well with non-eagerly simplifying unions Created: 26/Sep/13  Updated: 26/Sep/13

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

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


 Description   

Bug introduced in 0.2.11.

(cf (fn> [a :- (U nil (Nilable java.util.Date))]
(when a
(ann-form a java.util.Date))))

Type Error (clojure.core.typed:1:87) Local binding a expected type java.util.Date, but actual type (U (Nilable java.util.Date) nil)
in: a

Type Error (clojure.core.typed:1:87) Type mismatch:

Expected: java.util.Date

Actual: (U (Nilable java.util.Date) nil)
in: a

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






[CTYP-70] Having trouble typing core.string/blank? Created: 24/Sep/13  Updated: 20/Jul/14  Resolved: 20/Jul/14

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

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


 Description   

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

(cf (ann core.string/blank? [String -> Boolean]))

(ann x [String -> Boolean])
(defn x [s] (s/blank? s))

Fails.

Apologies if this is wrong.



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

I think core.string/blank? should be clojure.string/blank?. Also cf is not allowed inside a typed file.

Comment by Julian Birch [ 28/Sep/13 2:58 PM ]

Clunk. You're absolutely right. Assuming there's no (cf) there, is there any way you could log an error for an annotation with no associated actual definition? Obviously, to be useful, it'd have to appear in the appropriate location in the file.

Comment by Ambrose Bonnaire-Sergeant [ 28/Sep/13 10:16 PM ]

I don't know. Perhaps at the end of type checking a namespace I can check if a var exists for each annotation. I don't think it's really feasible for REPL development though.





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

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

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


 Description   

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

(defrecord X [x])

; lein typed check spong

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



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

This might be a regression from 0.2.9.

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

Verify with 0.2.10-20130923.021130-2





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

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

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


 Description   

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

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

but it should pass.



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

Had a quick look

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

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

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

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

Found issue:

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

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

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

Global annotations are only collected during type checking.

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

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

FWIW this might change in the future to defonce semantics.

There are a couple of other issues here.

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

A couple of approaches to fixing this:

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

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

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

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

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

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

OK, assoc seems to be behaving itself under 0.2.11.

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

This passed, and I think should pass:

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

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

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





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

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

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


 Description   

(cf compare)

gives

(Fn [Comparable Any -> Number])

but

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

fails the type check.

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



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

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





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

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

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

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

 Description   

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



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

Squashed the commits together into one

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

Applied in 0.2.8





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

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

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


 Description   

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



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

Fixed in 0.2.9





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

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

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


 Description   

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

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



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

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

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

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

gives

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

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

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

Yes, I fixed the wrong bug.

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

Should really be fixed in 0.2.10

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

Fixed in master:

Addressing point 2:

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

Point 3:

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




[CTYP-63] ann-record should accept optional binder Created: 16/Sep/13  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   

ann-precord should be deprecated and consolidated with ann-record.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 11:03 PM ]

Fixed sometime before 0.2.59





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

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

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


 Description   

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

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

I think the smaller case is:

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


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

Maybe helpful for debugging, correct and incorrect smaller cases:

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

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

Please verify with 0.2.8-20130918.094405-3





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

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

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


 Description   

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

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

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

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

Smaller test case:

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


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

s/attributes/keys

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

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

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

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

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

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

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

Fixed in 0.2.8

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





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

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

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


 Description   

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

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

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

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

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



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

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

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

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

Verified via IRC.





[CTYP-59] Return accurate type from first for heterogenous vectors Created: 14/Sep/13  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: Minor
Reporter: Chris Spencer Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

(first [1 'a]) currently typed as (U (Value a) (Value 1)) rather than (Value 1)



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 11:08 PM ]

Fixed in CTYP-142: http://dev.clojure.org/jira/browse/CTYP-142





[CTYP-58] nth can't be used on Sets, but type checks as ok Created: 14/Sep/13  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: Minor
Reporter: Chris Spencer Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

(nth #{5} 4) checks as ok, but fails at runtime. Just need a more accurate type for nth.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 20/Jul/14 11:05 PM ]

Fixed sometime before 0.2.59 https://github.com/clojure/core.typed/blob/master/module-check/src/test/clojure/clojure/core/typed/test/core.clj#L2966-2972





[CTYP-57] Support monitor-enter/monitor-exit Created: 13/Sep/13  Updated: 13/Sep/13

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

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





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

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

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


 Description   

Does not need special type for occurrence typing.



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

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

Will be included in 0.2.11





[CTYP-55]  clojure.lang.RT/longCast is interpreted incorrectly Created: 11/Sep/13  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: Minor
Reporter: Chris McDevitt Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: bug


 Description   

tested version: 0.2.5

Functions that cast to long like neg? / pos? don't work with type checking. eg. (cf (pos? (dec 1)))

> (cf (long (dec 1)))

Type Error (myapp.core:1:5) Type mismatch:

Expected: 	long

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


 Comments   
Comment by Chris McDevitt [ 11/Sep/13 12:03 PM ]

workaround is (cf (#'pos? (dec 1)))

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

Fixed sometime before 0.2.58





[CTYP-54] Merge compatible types to make more accurate ones Created: 11/Sep/13  Updated: 11/Sep/13

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

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


 Description   

We need to figure out how to merge types like (I (Vec Any) (Seqable Number)). A general solution is probably needed: we want a way for new types to "plug in" to this behaviour.

This needs to be considered in Clojurescript too, where Vec and Seqable are implemented as protocols and do not have an inheritance relationship.

(From https://gist.github.com/pnf/e208b0d44860aedc9c9d)

;; There seems to be some difficulty in merging the two assertions here.
(t/ann testassert6 [(t/Vec Any) -> (t/Vec t/AnyInteger)])
(defn testassert6 [m]
(assert (vector? m)) ; this should be redundant
(assert (every? integer? m))
m)
;; Type Error (imdb.testassert:92) Local binding m expected type (t/Vec t/AnyInteger), but actual type (I (IPersistentVector Any) (t/Coll t/AnyInteger))
;; in: m
;; Type Error (imdb.testassert:92) Type mismatch:
;; Expected: (t/Vec t/AnyInteger)
;; Actual: (I (IPersistentVector Any) (t/Coll t/AnyInteger))
;; in: (do (if (clojure.core/vector? m) nil (throw (new java.lang.AssertionError #))) (if (clojure.core/every? clojure.core/integer? m) nil (throw (new java.lang.AssertionError #))) m)
;; Type Error (imdb.testassert:92:1) Type mismatch:
;; Expected: (Fn [(t/Vec Any) -> (t/Vec t/AnyInteger)])
;; Actual: (Fn [(t/Vec Any) -> (I (IPersistentVector Any) (t/Coll t/AnyInteger)) :filters {:then (& (is (IPersistentVector Any) 0) (! (U nil false) 0)), :else (is (U nil false) 0)} :object {:id 0}])
;; in: (def testassert6 (fn* ([m] (do # # m))))






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

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

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


 Description   

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

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

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

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



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

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





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

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

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

ClojureScript 0.0-1859, Mac OS X 10.8.4



 Description   

Following code snipped exemplifies the error:

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

Produces the following error when type-checking:

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

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

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

Ranges:
x
(U y x)

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






[CTYP-51] assoc unsupported in CLJS Created: 10/Sep/13  Updated: 10/Sep/13

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

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

ClojureScript 0.0-1859, Mac OS X 10.8.4



 Description   

Simple snippet of code that exemplifies the defect:

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






[CTYP-50] Support overriding fields Created: 09/Sep/13  Updated: 09/Sep/13

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

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


 Description   

Give the user tools to give better types to Java fields.






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

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

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


 Description   

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



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

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

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

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

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

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





[CTYP-48] Internal error: keyword invoke gave bottom type Created: 06/Sep/13  Updated: 06/Sep/13

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

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


 Description   

Invoking keyword keys on things that are not maps, or maps that don't have the "correct" keys throws an internal type error. This should be a warning and return Any.

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



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

Fixed in master: https://github.com/clojure/core.typed/commit/26166595addde1d97d96db57baf154c3e19330c6

Verify with version:

[org.clojure/core.typed "0.2.5-20130907.040255-3"]
:repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}





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

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

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


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

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

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



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

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

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

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

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

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





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

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

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


 Description   

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



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

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





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

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

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

Clojure 1.5, core.typed 0.2.2



 Description   

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

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

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

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

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



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

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

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

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





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

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

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


 Description   

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



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

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

and

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





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

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

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


 Description   

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



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

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





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

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

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

clojure.core.typed 0.2.2



 Description   

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

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



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

Confirmed.

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

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

Could you try Michael?

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

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

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

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

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

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

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

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

Please verify with: 0.2.5-20130908.112056-6

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

Michael reported this as fixed.





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

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

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


 Description   

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

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

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

Thanks!



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

Fixed in master.

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

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





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

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

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

Safari 6.0.5 and Firefox 22.0 on Mac OS X 10.8.4



 Description   

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

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



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

This should be fixed in 0.2.5-20130907.135349-4

Please give it a shot.

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

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





[CTYP-39] def-alias not working in ClojureScript Created: 02/Sep/13  Updated: 02/Sep/13

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

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

Safari 6.0.5 and Firefox 22.0 on Mac OS X 10.8.4



 Description   

Using def-alias results in a runtime JavaScript exception, possibly indicating that it's not implemented.

Safari: TypeError: 'undefined' is not an object (evaluating 'cljs.core.typed.def_alias_STAR_')
Firefox: [13:58:34.654] TypeError: cljs.core.typed is undefined @ http://localhost:3000/js/chaser.js:21780






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

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

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


 Description   

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

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

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

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


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

This is not an issue with inner class syntax.

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

core.typed doesn't yet support overriding fields.

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

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





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

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

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


 Description   

Reported by Michael Hanson.

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



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

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

Fixed in 0.2.6-20130915.134318-3





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

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

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


 Description   

Otherwise caching is unsound.

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



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

Added Poly-fresh*





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

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

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


 Description   

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

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






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

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

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


 Description   

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

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

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



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

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





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

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

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


 Description   

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

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

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

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


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

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





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

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

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


 Description   

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

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

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






[CTYP-31] Error with unannotated datatypes. Created: 23/Jul/13  Updated: 20/Jul/14  Resolved: 20/Jul/14

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

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

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



 Description   

From mail;
> > > Hmm. Is LocalConnection a datatype? What's the error you get?
> >
> > This: (t/ann ^:nocheck datomic.api/connect [String -> datomic.peer.LocalConnection])
> > Produces: AssertionError Assert failed: ((u/array-map-c? symbol? (some-fn Scope? Type?)) fields) clojure.core.typed.type-rep/->DataType (type_rep.clj:265)
>
> Thanks.
>
> core.typed doesn't like unannotated datatypes right now. This is probably a defect, please open a ticket.



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

I believe this is more graceful now.





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

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

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

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



 Description   

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

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



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

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





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

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

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

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



 Description   

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



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

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

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

(map + [1.1]
=> constraint gen error

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

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

The particular issue here can be fixed with:

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

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

This is not a limitation of LTI.

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

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

Thanks for the report Alan!





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

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

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


 Description   

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



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

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





[CTYP-27] clojure.lang.RT/nth's type doesn't currently allow nil as the first argument Created: 23/Jul/13  Updated: 27/Jul/13

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

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


 Description   

Re: Why (first [1 2 3]) isn't equivalent to (let [[x & xs] [1 2 3]] x)
"
; This is because clojure.lang.RT/nth's type doesn't currently allow nil as
; the first argument. Should be fixed in master, but please submit a bug report to
; JIRA, it might not be completely correct.
; -Ambrose"

From
https://github.com/frenchy64/type-examples/blob/master/src/type_examples/core.clj

I'm not sure if this is fixed in master, but I couldn't build the current 0.1.18-SNAPSHOT (master) to check.



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 23/Jul/13 6:09 AM ]

Sorry, master is a bit broken at the moment. It may take a week to get it stable actually!

Comment by Ambrose Bonnaire-Sergeant [ 27/Jul/13 9:41 AM ]

This needs a special case for invoke-nth, to handle things like (nth (I (Seqable x) (CountRange 1)) 0).





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

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

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


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

Add Extends type.





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

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

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


 Description   

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



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

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





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

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

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


 Description   

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



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

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

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





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

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

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


 Description   

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

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


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

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

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


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

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





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

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

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


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

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


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

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

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

Fixed.

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

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





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

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

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


 Description   

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



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

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

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

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

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

Fixed, verified by above test.





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

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

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


 Description   

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

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

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

Code to reproduce / fix:

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



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

Thanks for the report, fixed.

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





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

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

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


 Description   

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

For example:

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

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

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

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

When

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

is changed to

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

checking works.

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



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

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

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

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





[CTYP-18] Implement equality filters Created: 10/Mar/13  Updated: 10/Mar/13

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   

Equality filters show that two local bindings are essentially equivalent (eg. aliased). This is useful where macros alias user-known locals with gensyms, like in :as map destructuring.






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

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

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


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

This can wait.





[CTYP-16] Parameterise IFn instead of special function type. Created: 08/Mar/13  Updated: 16/Sep/13

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

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


 Comments   
Comment by Chris Spencer [ 16/Sep/13 5:54 AM ]

Need to support primitive hinted functions too:

user=> (defn f [^long x] x)
#'user/f
user=> (clojure.tools.analyzer/analyze-form '(fn [] (f 5)))
{:op :fn-expr, :env {:line 1, :locals {}, :ns {:name user}}, :methods ({:op :fn-method, :env {:locals {}, :ns {:name user}}, :body {:op :do, :env {:source "NO_SOURCE_FILE", :column 46, :line 1, :locals {}, :ns {:name user}}, :exprs ({:op :instance-method, :env {:source "NO_SOURCE_FILE", :column 46, :line 1, :locals {}, :ns {:name user}}, :target {:op :var, :env {:locals {}, :ns {:name user}}, :var #'user/f, :tag clojure.lang.IFn$LO}, :method-name "invokePrim", :method #clojure.reflect.Method{:name invokePrim, :return-type java.lang.Object, :declaring-class clojure.lang.IFn$LO, :parameter-types [long], :exception-types [], :flags #{:public :abstract}}, :args ({:op :number, :env {:locals {}, :ns {:name user}}, :val 5}), :tag nil})}, :required-params (), :rest-param nil}), :variadic-method nil, :tag nil}




[CTYP-15] Eliminate the need to specify all ancestors in alter-class. Created: 08/Mar/13  Updated: 08/Mar/13

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

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





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

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

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

Attachments: File CTYP-14.diff    

 Description   

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

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



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

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

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

Merged.





[CTYP-13] Understand common contract functions Created: 03/Mar/13  Updated: 28/Aug/13

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   

juxt, every?, comp, partial, are very useful for type information.

The idiom (every? p? (keys m)) should cast maps.



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

Added support for every? in 0.1.25-SNAPSHOT.





[CTYP-12] Handle primitives properly Created: 03/Mar/13  Updated: 03/Mar/13

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   

Currently Java primitives can travel anywhere, without consideration for boxing.






[CTYP-11] Infer good types for loop locals Created: 03/Mar/13  Updated: 03/Mar/13

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