The first part of the error tells you this concerns a call to clojure.core/keys
. You can lookup the type with (cf keys)
.
(All [k]
[(Map k Any) -> (Seq k) :object {:id 0 :path [Keys]}])
The error is basically summarising this polymorphic type juxtaposed with the actual types provided to the function.
The Polymorphic Variables
list all the variables in the All
binder and their type bounds. k
is the only variable, which has essentially no bounds, so k
is displayed.
The Domains
list all the parameter types (to the left of the ->
) in order. If multiple arities were specified with Fn
, each parameter list would be displayed sequentially.
The Arguments
show you what types are actually passed to the function. The code at 14:23 is presumably this call (keys hm)
, so the type of the first argument is displayed: (t/Option (t/Map k v1))
The Ranges
list all the return types (to the right of the ->
) in order.
Sometimes there is an Expected
type, which must match up with a Range
in the same way all the Arguments
must match up with a Domain
.
We can diagnose this error by comparing the Domains
with the Arguments
. The list of Arguments
must fit under one list of Domains
, and the match is attempted top-down. If no Domains
fit with the Arguments
, we get a type error like this; it's often too complicated to pinpoint exactly where the constraint algorithm failed, so the user is presented with a lot of information.
In this case, we try and fit the argument (t/Option (t/Map k v1))
under the domain (t/Map k Any)
, which fails. This is because the argument (t/Option (t/Map k v1))
is the same as (U nil (t/Map k v1))
, and nil
does not fit under the domain (t/Map k Any)
.
There are a couple of ways to fix this. You basically need to ensure keys
isn't passed nil
. Here's one option:
(keys (or hm {}))