Hi Ambrose,
I have this example of a recursive type that I believe should pass, but isn't:
(defalias Json (t/Rec [x] (U nil
String
Number
String
Boolean
(t/Map String x)
(t/Seq x))))
;; Try and use the `map?` function to cast to the type we want
(ann get-object [Json -> (t/Option (t/Map String Json))])
(defn get-object [in]
(when (and in (map? in)) in))
The reasoning is that, by doing the (map?) check, the result can only be (t/Map String Json) or nil. However, this is the failure:
Type Error (rest_api/types.clj:369:28) Type mismatch:
Expected: (t/Option (t/Map String rest-api.types/Json))
Actual: (t/U (IPersistentMap String rest-api.types/Json) (t/I (IPersistentMap t/Any t/Any) (ISeq rest-api.types/Json)) (t/I (IPersistentMap t/Any t/Any) Number))
in: in
Some of the "Actual" types don't even make sense to me. How can a value be an intersection of a Map and a Number?
Thanks!
Matt