Uploaded image for project: 'core.typed'
  1. CTYP-277

Typechecking fails with internal assert error

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: 0.3.11
    • Fix versions: Backlog
    • Components: Clojure Checker
    • 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)
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: