-
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
Strange handling of complement / not #50
Comments
@vemv Thanks for reporting this! I had noticed this as well last night, and you're right, this is really confusing! I'll work on a fix. |
@vemv Unfortunately, it turns out that we can only do a little better in this case. The slash is really confusing, but the best I can do at this point is to print out "" since spec doesn't capture the original code. Here's what it looks like in my branch (compared to the default spec output for reference):
|
I can likely do better once https://dev.clojure.org/jira/browse/CLJ-2068 is fixed! |
Ah, nevermind:
|
OK, I've just released a new version of "0.3.4-SNAPSHOT" which contains these changes (you'll need to delete your old copy in |
BTW I don't think this really matters in practice, though. clojure.spec is not good at handling bare predicates in terms of error reporting while you can work around it by wrapping them with => (ex/expound (s/spec (complement str/blank?)) "")
-- Spec failed --------------------
""
should satisfy
(complement clojure.string/blank?)
-------------------------
Detected 1 error
nil
=> It also works to just => (s/def ::non-blank (complement str/blank?))
:user/non-blank
=> (ex/expound ::non-blank "")
-- Spec failed --------------------
""
should satisfy
(complement clojure.string/blank?)
-- Relevant specs -------
:user/non-blank:
(clojure.core/complement clojure.string/blank?)
-------------------------
Detected 1 error
nil
=> |
Hey there! Thank you, much better now 🍻 Perhaps if I realise turning defns into macros is bit of a dubious move (and a breaking change). Maybe |
@vemv Excellent, I'm glad it works. You're correct, if I suspect it could be done, but since wrapping the predicate in Thanks for testing the fix! |
I've just released 0.3.4, which includes this bug fix. |
Hi again!
By evaluating
(expound/expound (complement string/blank?) "")
one will get:The
/
is quite confusing.If I try with
(expound/expound (fn [x] (not (string/blank? x))) "")
I'll get the same output.Tried out with clojurescript.
Hope this one can be improved!
Cheers - Victor
The text was updated successfully, but these errors were encountered: