Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.typed by
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)

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CTYP-277 (reported by alex+import)
...