s/valid? vs. s/explain

166 views
Skip to first unread message

James Gatannah

unread,
Nov 13, 2016, 10:57:55 AM11/13/16
to Clojure
One of my system boundary data structures is particularly ugly.  It involves things like JNI classes wrapping native socket libraries, go loops, and higher-order functions that I can use to plug in message dispatchers.

I'm in the process of translating it from schema to spec. So far, the process has been very educational.

I've reached a point where calling (s/valid? ::foo x) returns false, but (s/explain ::foo x) returns nil.

Is this a bug in spec? Or am I misinterpreting the docstrings?

(Narrowing it down enough to identify/fix my actual problem is one thing. Getting something that's easily/obviously reproducible is going to be more difficult, just because the problem spans at least 3-4 different github repos).

Thanks,
James
 

James Gatannah

unread,
Nov 13, 2016, 11:20:11 AM11/13/16
to clo...@googlegroups.com
Turns out I was wrong about the minimal use case.

This particular problem was just an fdef that was missing a :ret spec.

That seems like a bug in s/explain, but I think it's a tossup whether
the bug's in the docstring or the implementation.

And I'm not entirely convinced that it's a bug at all. But it's
strange enough to seem worth mentioning/explaining.

Thanks again,
James
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/1gOBPLk5wpg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Josh Tilles

unread,
Nov 13, 2016, 11:22:33 AM11/13/16
to clo...@googlegroups.com
Just going on memory at the moment, but I’m pretty sure `s/explain` just writes to `*out*` (and thus always returns `nil`). You probably want `s/explain-data` or `s/explain-str`.

-Josh

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.

James Gatannah

unread,
Nov 13, 2016, 11:40:35 AM11/13/16
to clo...@googlegroups.com
s/explain doesn't produce any sort of error/output that I can see.

s/explain-data returns nil.

s/explain-str returns the last few lines printed by the function being
exercised. Maybe it captures output from the final test run?
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/1gOBPLk5wpg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

Alex Miller

unread,
Nov 13, 2016, 4:36:46 PM11/13/16
to Clojure
Any case where valid? returns false and explain-data returns nil is a bug.

James Gatannah

unread,
Nov 14, 2016, 11:14:28 PM11/14/16
to clo...@googlegroups.com
Ticket filed: http://dev.clojure.org/jira/browse/CLJ-2057

Thanks!

On Sun, Nov 13, 2016 at 3:36 PM, Alex Miller <al...@puredanger.com> wrote:
> Any case where valid? returns false and explain-data returns nil is a bug.
>

James Gatannah

unread,
Nov 17, 2016, 1:24:57 AM11/17/16
to Clojure
Thank you, Alex.

Both for the feedback about what I'm doing wrong and for a fix that looks simple and obvious.

Regards,
James
Reply all
Reply to author
Forward
0 new messages