plumatic / plumbing

Prismatic's Clojure(Script) utility belt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

defnk example using & and :as doesn't work

nahuel opened this issue · comments

defnk Example given at https://github.com/Prismatic/plumbing/tree/master/src/plumbing/fnk raises an exception:

(defnk foo [x & y :as z] [x y z])

java.lang.RuntimeException
   Got illegal special binding: clojure.lang.LazySeq@bce9dd88
                      impl.clj:  121  plumbing.fnk.impl/extract-special-arg
                      impl.clj:  134  plumbing.fnk.impl/letk-input-schema-and-body-form
                      impl.clj:  345  plumbing.fnk.impl/fnk-form
                     core.cljx:  435  plumbing.core$defnk/doInvoke
                   RestFn.java:  490  clojure.lang.RestFn/invoke
                      Var.java:  401  clojure.lang.Var/invoke
                      AFn.java:  171  clojure.lang.AFn/applyToHelper
                      Var.java:  700  clojure.lang.Var/applyTo

Thanks for the report! Currently if :as and & are present, :as must be first -- guess that example needs updating (and/or the code should be generalized to handle both). Either fix would be welcome if you want.

Fixed by #54