clojure-spec

Drew Verlee 2022-06-14T18:10:53.110029Z

I don't understand what spec is trying to tell me here. Isn't {:keys ... valid clojure?

-- Spec failed --------------------

  (... ... [{:keys [http-client max-retries backoff retry?], :as client} ...] ...)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

should satisfy

  vector?

-- Relevant specs -------

:clojure.core.specs.alpha/arg-list:
.... (more spec info...)

Victor Maia Aldecรดa 2022-06-14T18:14:13.735959Z

I don't understand either, but you can try to use this lib to get better spec messages: https://github.com/bhb/expound

Drew Verlee 2022-06-14T18:15:36.692409Z

that is expound formatted ๐Ÿ™‚

1
๐Ÿ˜… 1
Alex Miller (Clojure team) 2022-06-14T18:20:04.118519Z

Do you have the message without expound?

cjohansen 2022-06-14T18:32:14.144789Z

Throwing in a guess: maybe you forgot to put optional arguments in a vector? (defn blabla [a b & {:keys [c d]}] ,,,)

Drew Verlee 2022-06-14T20:36:08.127489Z

i could go back and re-create the errors it if it helps. The minimal change that made the errors go away was to

(defn foo [{:keys [x] :or {::x "x"}] x) 
to
(defn foo [{:keys [x] :or {x "x"}] x) 
note the :or {::x to to just x. that is, the value of the hashmap of the :or arg has to be a symbol not a key. This same error seemed to generate several different expound messages (at least thats how it seems to me).

Alex Miller (Clojure team) 2022-06-14T20:51:50.118729Z

the keys of :or are always the symbols being bound, which must be unqualified, so neither :x or ::x are valid in that spot

๐Ÿ‘ 2