Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Syntax and reader by


clj-rcon-test.core=> (defn- hi [as-codec & {:keys [offset] :or {:offset 0}}]
                #_=>   (println "hi"))


clj-rcon-test.core=> (defn- hi [as-codec & {:keys [offset] :or {:offset 0}}]
                #_=>   (println "hi"))
Syntax error macroexpanding clojure.core/defn- at (form-init17556793069765460591.clj:1:1).
:offset - failed: simple-symbol? at: [:fn-tail :arity-1 :params :var-params :var-form :map-destructure :or 0] spec: :clojure.core.specs.alpha/or
{:keys [offset], :or {:offset 0}} - failed: simple-symbol? at: [:fn-tail :arity-1 :params :var-params :var-form :local-symbol] spec: :clojure.core.specs.alpha/local-name
{:keys [offset], :or {:offset 0}} - failed: vector? at: [:fn-tail :arity-1 :params :var-params :var-form :seq-destructure] spec: :clojure.core.specs.alpha/seq-binding-form
as-codec - failed: vector? at: [:fn-tail :arity-n :bodies :params] spec: :clojure.core.specs.alpha/param-list


For context this is what I'm trying to troubleshoot: https://github.com/gpittarelli/clj-rcon/blob/master/src/clj_rcon/codecs.clj#L6

1 Answer

+5 votes
selected by
Best answer

The problem here is that :or expects a map of symbols to values, not keywords to values. Not sure if this was an oversight in the spec, or that it should never have been supported.

Thanks, that worked!
It was unintentionally allowed in the past and has been tightened up. Importantly it silently didn't work before.