[spec] :clojure.spec/invalid is not a valid :clojure.spec/any value
Description
Environment
Activity

Michiel Borkent December 30, 2018 at 10:35 PM
I modified the ::any
spec in speculative as follows:

Michiel Borkent December 30, 2018 at 2:40 PM
This is also a problem in tooling REPL like Cursive's. Repro:
Evaluating this namespace in a Cursive REPL gives:
The problem can also reproduced without Cursive by evaluating the above and this:

Former user July 6, 2018 at 3:05 PM
Please use sumtypes instead of "magic" values to indicate failure or success. For example,
Note that the return value should be an instance of clojure.lang.MapEntry, in order for key
and val
to work on it. However, if it's not desirable to return the explain-map on failure then returning vectors [:ok value]
and [:failure]
(no second element) would work as well.
Since spec is explicitly in alpha, it's not too late yet to fix the api.
Related:

Alexander Kiel September 13, 2017 at 12:34 PM
The macro issues can be solved by just not using ::s/invalid in code directly. I think in general, it better to use the predicate s/invalid?.
Instead of writing:
one should use
But I have no idea to solve the issue where you have ::s/invalid in data which is validated. The function spec for identical? is a good example.
world not work.
Ambrose Bonnaire-Sergeant September 5, 2017 at 9:41 PM
Another example from the wild: https://github.com/pjstadig/humane-test-output/pull/23
A macro rewriting
to
resulted in some very strange errors.
Details
Details
Assignee
Reporter

(clojure.spec/valid? :clojure.spec/any :clojure.spec/invalid)
returnsfalse
This issue gets serious, if one likes to write specs for core functions like
=
which are used by spec itself. I observed this bug as I wrote a spec forassoc
.A possible solution could be to use an
(Object.)
sentinel internally and:clojure.spec/invalid
only at the API boundary. But I have not thought deeply about this.