Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArityException when calling expound on a multi-spec with custom retag function #122

Closed
kennyjwilli opened this issue Aug 31, 2018 · 2 comments
Labels

Comments

@kennyjwilli
Copy link

Take this example code:

(ns dev.expound
  (:require
    [clojure.spec.alpha :as s]
    [clojure.spec.gen.alpha :as gen]
    [expound.alpha :as expound]))

(defmulti bar-spec :type)

(s/def ::b string?)

(defmethod bar-spec ::b
  [_]
  (s/keys :req [::b]))

(s/def ::bar (s/multi-spec bar-spec (fn [val tag]
                                      (assoc val :type tag))))

I realize in this trivial example the retag function should be :type but for the sake of producing the error in more complex cases, I made it a function.

Running (expound/expound ::bar {}) produces this exception:

clojure.lang.ArityException: Wrong number of args (1) passed to: expound/fn--1994
	at clojure.lang.AFn.throwArity(AFn.java:429)
	at clojure.lang.AFn.invoke(AFn.java:32)
	at expound.alpha$no_method.invokeStatic(alpha.cljc:255)
	at expound.alpha$no_method.invoke(alpha.cljc:245)
	at expound.alpha$eval1720$fn__1721$fn__1722.invoke(alpha.cljc:396)
	at clojure.core$map$fn__5587.invoke(core.clj:2745)
	at clojure.lang.LazySeq.sval(LazySeq.java:40)
	at clojure.lang.LazySeq.seq(LazySeq.java:49)
	at clojure.lang.LazySeq.first(LazySeq.java:71)
	at clojure.lang.RT.first(RT.java:685)
	at clojure.core$first__5106.invokeStatic(core.clj:55)
	at clojure.string$join.invokeStatic(string.clj:180)
	at clojure.string$join.invoke(string.clj:180)
	at expound.alpha$eval1720$fn__1721.invoke(alpha.cljc:397)
	at clojure.lang.MultiFn.invoke(MultiFn.java:260)
	at expound.alpha$eval1730$fn__1731.invoke(alpha.cljc:411)
	at clojure.lang.MultiFn.invoke(MultiFn.java:260)
	at expound.alpha$print_explain_data$iter__1855__1859$fn__1860$fn__1861.invoke(alpha.cljc:704)
	at expound.alpha$print_explain_data$iter__1855__1859$fn__1860.invoke(alpha.cljc:702)
	at clojure.lang.LazySeq.sval(LazySeq.java:40)
	at clojure.lang.LazySeq.seq(LazySeq.java:49)
	at clojure.lang.RT.seq(RT.java:528)
	at clojure.core$seq__5124.invokeStatic(core.clj:137)
	at clojure.core$apply.invokeStatic(core.clj:652)
	at clojure.core$apply.invoke(core.clj:652)
	at expound.alpha$print_explain_data.invokeStatic(alpha.cljc:701)
	at expound.alpha$print_explain_data.invoke(alpha.cljc:687)
	at expound.alpha$printer_str.invokeStatic(alpha.cljc:842)
	at expound.alpha$printer_str.invoke(alpha.cljc:824)
	at expound.alpha$expound_str.invokeStatic(alpha.cljc:904)
	at expound.alpha$expound_str.invoke(alpha.cljc:896)
	at expound.alpha$expound.invokeStatic(alpha.cljc:917)
	at expound.alpha$expound.invoke(alpha.cljc:914)
	at dev.expound$eval2002.invokeStatic(form-init5270577758905363292.clj:1)
	at dev.expound$eval2002.invoke(form-init5270577758905363292.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7062)
	at clojure.lang.Compiler.eval(Compiler.java:7025)
	at clojure.core$eval.invokeStatic(core.clj:3206)
	at clojure.core$eval.invoke(core.clj:3202)
	at clojure.main$repl$read_eval_print__8572$fn__8575.invoke(main.clj:243)
	at clojure.main$repl$read_eval_print__8572.invoke(main.clj:243)
	at clojure.main$repl$fn__8581.invoke(main.clj:261)
	at clojure.main$repl.invokeStatic(main.clj:261)
	at clojure.main$repl.doInvoke(main.clj:177)
	at clojure.lang.RestFn.invoke(RestFn.java:1523)
	at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__818.invoke(interruptible_eval.clj:87)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:657)
	at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1965)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1965)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invokeStatic(interruptible_eval.clj:85)
	at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:55)
	at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__863$fn__866.invoke(interruptible_eval.clj:222)
	at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__858.invoke(interruptible_eval.clj:190)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
@bhb
Copy link
Owner

bhb commented Sep 1, 2018

@kennyjwilli Thanks for reporting this! This is definitely a bug.

@bhb
Copy link
Owner

bhb commented Dec 1, 2019

@kennyjwilli Thanks again for reporting this! This has been fixed as of e27059a and will be included in the next release.

@bhb bhb closed this as completed Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants