-
Notifications
You must be signed in to change notification settings - Fork 0
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
Better reporting for evaluated-from when eval #4
Comments
Note that for your example: (let [options #{:a :b :c}]
(check! (eval `(s/map-of ~options any?)) {:d :d})) ...one also could have written: (let [options #{:a :b :c}]
(check! options (keys {:d :d}))) ...which results in a usable report:
So, the eval-specing pattern is probably quite rare and unproven atm. If not proven otherwise, we may consider the ugly reports a desirable feature - it signals that a spec was defined weirdly. |
The example you provide isn't correct because this spec would fails for any map. as a list of symbols is never included in the set of symbols; e.g.
I agree we should aim for rewriting the spec for example opposed to fixing this u-s if possible, just not sure if it's possible. |
Of course the example I gave would always fail; the point was about avoiding
You can also use this other syntax: (speced/defn foo [^{::speced/spec (comp (partial some #{:a :b :c}) keys)} options]
options) It having an equivalent reporting. There's nedap/speced.def#31 for making things more concise. |
I see no other way of using a var instead of a set directly with proper reporting. In your other example you're using the set directly, which is impossible in my situation where the set is dynamic. maybe I'm just not seeing it, but while your |
Ok, got it. How about moving the
|
That worked, seems proper enough not to warrant changes to the reporting for now. Thanks ! |
Problem statement
If a spec is dynamically created using
eval
theevaluated-from
part becomes unwieldy.example;
This is sometimes necessary if the actual spec is unknown. Using the var yields an unhelpful spec failure:
Proposal
quick testing suggests removing
eval
if it's the first form might fix the printing;Alternatives and comparison
map-of
does seem to work(eval ...
at the startThe text was updated successfully, but these errors were encountered: