Fork me on GitHub

I have a problem with, namely when calling query fn which is instrumented with this spec:

(s/def ::result-set-fn (s/fspec :args (s/cat :rs (s/coll-of any?))
                                :ret  any?))
It calls my result set fn with a bunch of garbage


So when callbacks have a fspec defined, they get called with random data if they are instrumented?


that's how the function is validated


it is a common source of surprise


I guess i need to instrument just a specific ns


there are options also on instrument you can use to bypass this


well, to provide stubs at least


Is there a way (or another function) to have spec/explain return just the spec errors and not the original data as well?


@fedreg why not just pull the errors out of the result of spec/explain? 🤷


or create your own fn explain-errors that does that and use it instead 🤷


@samueldev I was about to do just that but then decided to check if I had missed something that already existed. Guess that’s a no… thx!


@roklenarcic Yeah, I may revisit some of those fspecs in as I get more feedback from people. As @gfredericks says, the behavior you're seeing is what clojure.spec instrumentation is intended to do, but it can be surprising at first. And of course your specific :result-set-fn may well not accept any old collection -- but given that :row-fn can transform the result set data into, essentially, an arbitrary collection of any type of element, the :result-set-fn could potentially be called on any? types... We don't have parameterized types so we can't constrain the row function to map? -> T and then the result set function to coll-of T -> U...


This surprised me

1. In a CLJS namespace, define a function with a name that matches a valid HTML tag (e.g. "table" or "br" or whatever)
2. Create an (s/fdef ...) spec for it.

Result: every function in that namespace now evaluates to nil.


Just a local fluke in my current project, or something that other people can reproduce?


If the latter, known issue, or new?