-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fails to report spec error when a non-fn IFn value doesn't conform to a fspec #41
Comments
Thanks very much for reporting this bug! This is a tricky one to solve in general. A little context: Expound uses the data returned by This "explain-data" contains a "value" (which is the top-level form) and a sequence of problems, each of which contains (among other things) a "val" (which points to the bad value) and an "in" (which is the path to the bad value). For example: (require '[clojure.spec.alpha :as s])
(s/explain-data (s/coll-of int?) [1 2 :a])
;; explain-data is:
;; #:clojure.spec.alpha{:problems ({:path [], :pred int?, :val :a, :via [], :in [2]}), :spec #object[clojure.spec.alpha$every_impl$reify__934 0xdfe0a61 "clojure.spec.alpha$every_impl$reify__934@dfe0a61"], :value [1 2 :a]} In this example, there is just one "problem". The value is In this simple case, the Expound has a lot of code dedicated to figuring out the However, in the case of As a result, we get this bug - Expound can't figure out how to interpret the My first impression is that it's not possible to solve this in general until one or both of the above Jira issues are fixed. However, there may be a way to solve this in at least some cases. I'll think more about this. |
@athos Thanks again for reporting this! I don't think it's possible to fix this in every case, but I think I have a heuristic for the more common cases. Can you try out |
Thank you for the quick reply and polite explanation about the context. I looked into the issue today, and now I see the difficulty of giving a general solution to it. In general, a return value generated by a So, yeah, I think your new PR now resolves the issue to some extent, and it would be sufficient for practical problems IMHO. |
Excellent! I took a quick look at Pinpointer and it looks great! I'll look take a look at Jira issues you've opened for spec and vote them up. Anything that makes it easier to build something like Expound or Pinpointer helps everyone :) |
@athos I've released version 0.3.3 which contains this fix. Thanks for your help! |
Repro:
Expected Expound would report the spec error that the input value didn't conform to the fspec, but throws a misleading error that says there may be a conformer (which is not true, in fact).
The text was updated successfully, but these errors were encountered: