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

cast doesn't work for recursive types

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Declined
    • Affects versions: 0.3.19
    • Fix versions: Backlog
    • Components: Core type system
    • Labels:
      None

      Description

      I have a simple recursive type for Json and JsonMaps:

      (t/defalias Json
        (t/Rec [v]
               (t/U t/Str
                    t/Num
                    t/Bool
                    (t/Value nil)
                    (t/Vec v)
                    (t/Map t/Str v))))
      
      (t/defalias JsonMap
        (t/Map t/Str Json))
      

      These seem to work fine for type checking and as predicates, but raise when I use them to cast a value:

      (t/cast sf/Json {})
      ExceptionInfo Internal Error (*cider-repl sails-forth*:395:6) :Rec not supported in type->pred: (t/Rec [v] (t/U t/Str t/Num t/Bool (t/Value nil) (t/Vec v) (t/Map t/Str v)))  clojure.core/ex-info (core.clj:4593)
      
      (t/cast sf/JsonMap {})
      ExceptionInfo Internal Error (*cider-repl sails-forth*:397:6) Don't know how to apply type: (clojure.lang.IPersistentMap k v)  clojure.core/ex-info (core.clj:4593)
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: