<< Back to previous view

[CTYP-306] pred doesn't work for non-literal HVecs with varargs Created: 29/Jan/16  Updated: 03/Dec/17

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

Type: Defect Priority: Major
Reporter: Donald Ball Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Problem

Predicate generation for HVec's do not support uniform variable parameters.

((t/pred (t/HVec [(t/Value :foo) t/Keyword *])) [:foo :bar])
CompilerException clojure.lang.ExceptionInfo: Internal Error (*cider-repl service*:97:17) :Protocol not supported in type->pred: * {:type-error :clojure.core.typed.errors/internal-error, :env {:line 97, :column 17, :file "*cider-repl service*", :ns spark.dev.repl}}, compiling:(*cider-repl service*:97:17)

Solution

This seems to be a symptom of * not being parsed correctly.

First, HVec's clearly ignores the variable parameters when they are parsed.

This is actually correctly done for quoted HVec types like '[Foo Bar *] here.

This change should fix things; the contract generation already works for quoted HVec's since it expects a rest entry,

Pull request:
Commit:
Version:



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 29/Jan/16 11:53 AM ]

The error is a bit odd. It may be that t/Keyword is the thing that's failing here.

Please try and isolate this error.

Comment by Ambrose Bonnaire-Sergeant [ 29/Jan/16 11:53 AM ]

Oh I see the issue. Cannot resolve Protocol called `*`!





[CTYP-282] Internal error with t/defn, sort-by and no refer all Created: 24/Oct/15  Updated: 03/Dec/17

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

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

org.clojure/core.typed 0.3.12



 Description   

How to reproduce:

(require 'clojure.core.typed)
(clojure.core.typed/cf (clojure.core.typed/defn foo [] sort-by))

It does seem to reproduce somewhat flakily within existing REPL environments depending on what you've run in the past. This will consistently reproduce it:

docker run -i -t clojure bash
echo '{:user {:plugins [[lein-try "0.4.3"]]}}' > ~/.lein/profiles.clj
lein try org.clojure/core.typed

(require 'clojure.core.typed) ;; does not work with refer all
(clojure.core.typed/cf (clojure.core.typed/defn foo [] sort-by))

Observed result:

Initializing core.typed ...
Building core.typed base environments ...
Finished building base environments
"Elapsed time: 5836.201655 msecs"
core.typed initialized.
DEPRECATED SYNTAX (/tmp/form-init6540853594514266546.clj:1:24): All syntax is deprecated, use clojure.core.typed/All
Type Error (/tmp/form-init6540853594514266546.clj:1:24) Internal Error (/tmp/form-init6540853594514266546.clj:1:24) Cannot resolve type: IFn
Hint: Is IFn in scope?
Hint: Has IFn's annotation been found via check-ns, cf or typed-deps?
Error

Desired result:

Correct type returned.



 Comments   
Comment by Vince Broz [ 03/Dec/17 8:06 PM ]

Hi! I just reproduced this issue using the docker recipe above (which uses the current version of org.clojure/core.typed. Did you try using the Docker recipe? Suggest reopening.

Comment by Ambrose Bonnaire-Sergeant [ 03/Dec/17 9:11 PM ]

Thanks, I appreciate the followup! I think there's something fishy going on with a subset of the base type environment that's shared between the CLJ and CLJS checkers.





[CTYP-279] An invalid type annotation for a function with a record argument passes a type check Created: 25/Sep/15  Updated: 03/Dec/17

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

Type: Defect Priority: Major
Reporter: kshramt Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Following code (unexpectedly) passes a type check.

(ns tst
  (:require
   [clojure.core.typed :refer [Int Kw ann] :as typed]))

(typed/defprotocol [[a :variance :covariant]] P
                   (f [p :- (P a)] :- a))

(typed/ann-record [[a :variance :covariant]] R [_f :- a])
(defrecord R [_f]
  P
  (f [self] _f))

(ann fr [(R Int) -> Kw])
(defn fr [x] (f x))





[CTYP-277] Typechecking fails with internal assert error Created: 16/Sep/15  Updated: 03/Dec/17

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

Type: Defect Priority: Major
Reporter: Aliaksandr Barouski Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Clojure 1.7.0



 Description   

When I try to typecheck record, that implements untyped protocol, I get internal assertion error. Minimal example:

(defprotocol Lifecycle
  (start [component])
  (stop [component]))

(t/ann-record TestRec [host :- String
                       port :- Integer
                       connection :- String])
(defrecord TestRec [host port connection]
  Lifecycle
  (start [component]
    (let [connection (str "Host: " host ", port: " port)]
      (assoc component :connection connection)))
  (stop [component]
    (.close connection)))

Exception:

java.lang.AssertionError: Assert failed: (every? r/Type? types)
 at clojure.core.typed.type_ctors$In.doInvoke (type_ctors.clj:498)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:630)
    clojure.core.typed.assoc_utils/fn (assoc_utils.clj:40)
    clojure.core.typed.assoc_utils$fn__10$G__5__17.invoke (assoc_utils.clj:25)
    clojure.core.typed.type_ctors$reduce_type_transform$fn__7210$iter__7211__7217$fn__7218.invoke (type_ctors.clj:2200)
    clojure.lang.LazySeq.sval (LazySeq.java:40)
    clojure.lang.LazySeq.seq (LazySeq.java:49)
    clojure.lang.RT.seq (RT.java:507)
    clojure.core/seq (core.clj:137)
    clojure.core$some.invoke (core.clj:2569)
    clojure.core.typed.type_ctors$union_or_nil.invoke (type_ctors.clj:2180)
    clojure.core.typed.type_ctors$reduce_type_transform.doInvoke (type_ctors.clj:2195)
    clojure.lang.RestFn.invoke (RestFn.java:494)

Debug print in error position:

(:types new-i) => #{{:the-class clojure.core.typed.test.records3.TestRec,
    :variances nil,
    :poly? nil,
    :fields
    {host {:id java.lang.String},
     port {:id java.lang.Integer},
     connection {:id java.lang.String}},
    :record? true}
   {:variances nil,
    :poly? nil,
    :the-class clojure.core.typed.test.records3.Lifecycle}}

(map #(assoc-type-pairs % assoc-entry) (:types new-i)) =>
({:the-class clojure.core.typed.test.records3.TestRec,
  :variances nil,
  :poly? nil,
  :fields
  {host {:id java.lang.String},
   port {:id java.lang.Integer},
   connection {:id java.lang.String}},
  :record? true}
 nil)





[CTYP-275] Bad call to path-type: nil Created: 15/Sep/15  Updated: 03/Dec/17

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

Type: Defect Priority: Major
Reporter: Mark Feeney Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Discussion: https://groups.google.com/d/msg/clojure-core-typed/-4XzTLD1LNE/LuJqMuNzAgAJ

(t/cf (t/fn [x :- (t/Option '[t/Num])] (let [[a] x] a)))
Type Error (...) Internal Error (...) Bad call to path-type: nil, ({:idx 0})





[CTYP-274] Inferred type for {{defn}} and {{typed/fn}} with the same body are different Created: 08/Sep/15  Updated: 03/Dec/17

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

Type: Defect Priority: Major
Reporter: kshramt Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Following code passes a type check as expected:

(ann self-evaluating?
     [Any -> Boolean
      :filters {:then (is (U String Number) 0)
                :else (! (U String Number) 0)}])
(defn self-evaluating? [exp]
  (let [impl (typed/fn [x :- Any]
               (or (number? x)
                   (string? x)))]
    (impl exp)))

However, if I unwrap the typed/fn, it does not pass a type check:

(ann self-evaluating?
     [Any -> Boolean
      :filters {:then (is (U String Number) 0)
                :else (! (U String Number) 0)}])
(defn self-evaluating? [exp]
  (or (number? exp)
      (string? exp)))
Type Error (sicp/ch_4.clj:353:3) Expected result with filter {:then (is (U String Number) exp__#0), :else (! (U String Number) exp__#0)}, got filter {:then (& (| (is (U nil false) or__4238__auto____#0) (is Number exp__#0)) (| (! Number exp__#0) (! (U nil false) or__4238__auto____#0))), :else (& (| (is (U nil false) or__4238__auto____#0) (is Number exp__#0)) (| (! Number exp__#0) (! (U nil false) or__4238__auto____#0)))}
in: (if or__4238__auto__ or__4238__auto__ (string? exp))





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

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

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


 Description   

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

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





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

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

Type: Defect Priority: Major
Reporter: Vince Broz Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: hmap, occurrence-typing


 Description   

How to reproduce:

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

Observed result:

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

Expected result (pseudeocode):

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

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

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

Details:

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

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





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

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

Type: Defect Priority: Major
Reporter: victor chung Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

osx
clojure 1.6



 Description   

Code is here:

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



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

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





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

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

Type: Defect Priority: Major
Reporter: Timo Mihaljov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

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



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

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





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

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

Type: Defect Priority: Major
Reporter: Colin Yates Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

The following code:

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

gives the following error:

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





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

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

Type: Defect Priority: Major
Reporter: Reno Reckling Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

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

Code:

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

(declare dispatcher)

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

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

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

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

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

Error message:

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

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

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

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

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


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


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


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


Domains:
	Object

Arguments:
	t/Any

Ranges:
	(t/U nil Object)

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


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


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


Domains:
	Object

Arguments:
	t/Any

Ranges:
	(t/U nil Class)

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


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


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


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


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


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

Expected: 	(t/U nil MethodImplCache)

Actual: 	t/Any
in: cache__5917__auto__


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

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

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

Ranges:
	w

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


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


Type Checker: Found 13 errors
Found errors
Subprocess failed





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

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

Type: Defect Priority: Major
Reporter: Joshua Griffith Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: bug, defprotocol, deftype
Environment:

Clojure 1.6.0 and 1.7.0-alpha5


Attachments: File arity.clj     Text File typecheck.log    

 Description   

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



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

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

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

with clojure 1.7.0-beta2 and core.typed 0.2.87

(ns core-typed-bug.core
  (:require [ clojure.core.typed :as t ]))
 
(t/defprotocol P
  (f
   [a] :- Any
   [a b :- Any] :- Any))
 
(t/ann-record R [])
(defrecord R []
  P
  (f [a] 1)
  (f [a b] 2))

will give the following arity related errors:

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




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

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

Type: Defect Priority: Major
Reporter: Daniel Ziltener Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

core.typed 0.2.77



 Description   

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

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






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

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

Type: Defect Priority: Major
Reporter: Johan Gall Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


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

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

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

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

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

The following works fine.

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





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

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

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


 Description   

These unit tests should pass.






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

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

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

core.typed 0.2.25


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

 Description   

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

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

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

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

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



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

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

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

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

Hi Cees,

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





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

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

Type: Defect Priority: Major
Reporter: Russell Mull Assignee: Unassigned
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-32] Cannot instantiate variables that have bounds Created: 29/Jul/13  Updated: 03/Dec/17

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

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


 Description   

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

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

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






Generated at Sun Jan 21 21:01:23 CST 2018 using JIRA 4.4#649-r158309.