Skip to content
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

Tuple with set predicate not reported correctly #67

Closed
arichiardi opened this issue Feb 1, 2018 · 9 comments
Closed

Tuple with set predicate not reported correctly #67

arichiardi opened this issue Feb 1, 2018 · 9 comments
Labels

Comments

@arichiardi
Copy link
Contributor

Hi again 😄 I have a bit of an improvement request 😄

I have a spec with a set predicate:

(s/def :stm/success-state (s/tuple #{:start :end :latest-event :attempt-commit}
                                   any?
                                   nil?))

Spec error was:

Error: Spec assertion failed
In: [0] val: :error fails at: [0] predicate: #{:start :end :latest-event :attempt-commit}
In: [2] val: #object[Error Error: Oh noes!] fails at: [2] predicate: nil?
:cljs.spec.alpha/spec  :stm/success-state
:cljs.spec.alpha/value  [:error nil #object[Error Error: Oh noes!]]
:cljs.spec.alpha/failure  :assertion-failed

And expound error:

Error: Call to #'expound.alpha/value-in-context did not conform to spec:
<filename missing>:<line number missing>
-- Spec failed --------------------

Function arguments

  (... 0 ... ... ...)
       ^

should be one of: `:args`,`:fn`,`:ret`



-- Spec failed --------------------

Function arguments

  (... 0 ... ... ...)
       ^

should satisfy

  nil?



-------------------------


@arichiardi arichiardi changed the title Set predicate not reported correctly Tuple with set predicate not reported correctly Feb 1, 2018
@bhb bhb added the bug label Feb 1, 2018
@bhb
Copy link
Owner

bhb commented Feb 1, 2018

@arichiardi Thanks for reporting this! Just to make sure I understand the repro, do you mind pasting the call that triggered this? Was it an instrumented function call?

@bhb
Copy link
Owner

bhb commented Feb 2, 2018

@arichiardi Thanks again for reporting this! I'm unable to repro, so I suspect I'm not doing the repro steps correctly 😄

Here is what I tried on the REPL with Expound 0.4.0

(require '[clojure.spec.alpha :as s])
(require '[clojure.spec.test.alpha :as st])
(require '[expound.alpha :as expound])
(set! s/*explain-out* expound/printer)
(st/instrument)
(s/def :stm/success-state (s/tuple #{:start :end :latest-event :attempt-commit}
                                   any?
                                   nil?))
(expound/expound :stm/success-state [:error nil {}])

And I got

-- Spec failed --------------------

  [:error ... ...]
   ^^^^^^

should be one of: `:latest-event`,`:start`,`:attempt-commit`,`:end`

-- Relevant specs -------

:stm/success-state:
  (clojure.spec.alpha/tuple
   #{:latest-event :start :attempt-commit :end}
   clojure.core/any?
   clojure.core/nil?)

-- Spec failed --------------------

  [... ... {}]
           ^^

should satisfy

  nil?

-- Relevant specs -------

:stm/success-state:
  (clojure.spec.alpha/tuple
   #{:latest-event :start :attempt-commit :end}
   clojure.core/any?
   clojure.core/nil?)

-------------------------
Detected 2 errors

I tried on Clojure 1.9.0 and Clojurescript 1.9.946. Are you on different versions?

@arichiardi
Copy link
Contributor Author

Oh ok the test seems fine, thanks for trying it out!
The only difference is that I am running on lumo, so maybe that is why the errors are reported differently.

@bhb
Copy link
Owner

bhb commented Feb 2, 2018

@arichiardi Interesting! I haven't tried it on lumo, so I'll need to look into that. I haven't had a chance to use lumo much - is there a relevant config file you can share that sets up the version of Expound and Clojurescript?

@arichiardi
Copy link
Contributor Author

Not at the keyboard now but probably I should check what expound relies on and check if lumo provides it correctly

@arichiardi
Copy link
Contributor Author

arichiardi commented Feb 2, 2018

The script you tried up there basically works the same with lumo, you could just:

$ lumo script.cljs

It should work, make sure you install the latest:

npm install -g lumo-cljs@1.8.0-beta

https://www.npmjs.com/package/lumo-cljs

@bhb
Copy link
Owner

bhb commented Feb 3, 2018

@arichiardi Unfortunately, I'm still having trouble reproducing. Here are my steps:

  1. npm install -g lumo-cljs@1.8.0-beta
  2. Run script in lumo:
lumo -c ~/.m2/repository/org/clojure/test.check/0.9.0/test.check-0.9.0.jar:~/.m2/repository/org/clojure/spec.alpha/0.1.143/spec.alpha-0.1.143.jar:~/.m2/repository/expound/expound/0.4.0/expound-0.4.0.jar
Lumo 1.8.0-beta
ClojureScript 1.9.927
Node.js v8.5.0
 Docs: (doc function-name-here)
       (find-doc "part-of-name-here")
 Source: (source function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as st])
nil
cljs.user=> (require '[expound.alpha :as expound])
nil
cljs.user=>
cljs.user=> (st/instrument)
[expound.printer/indent
 expound.paths/prefix-path?
 expound.alpha/specs
 expound.paths/kvps-path?
 expound.alpha/value-in-context
 expound.printer/pprint-str
 expound.paths/kps-path?
 expound.problems/summary-form
 expound.printer/no-trailing-whitespace]
cljs.user=>
cljs.user=> (set! s/*explain-out* expound/printer)
#object[expound$alpha$printer]
cljs.user=>
cljs.user=> (s/def :stm/success-state (s/tuple #{:start :end :latest-event :attempt-commit}
       #_=>                                    any?
       #_=>                                    nil?))
:stm/success-state
cljs.user=>
cljs.user=> (expound/expound :stm/success-state [:error nil {}])
-- Spec failed --------------------

  [:error ... ...]
   ^^^^^^

should be one of: `:start`,`:end`,`:latest-event`,`:attempt-commit`

-- Relevant specs -------

:stm/success-state:
  (cljs.spec.alpha/tuple
   #{:start :end :latest-event :attempt-commit}
   cljs.core/any?
   cljs.core/nil?)

-- Spec failed --------------------

  [... ... {}]
           ^^

should satisfy

  nil?

-- Relevant specs -------

:stm/success-state:
  (cljs.spec.alpha/tuple
   #{:start :end :latest-event :attempt-commit}
   cljs.core/any?
   cljs.core/nil?)

-------------------------
Detected 2 errors
nil

Just double checking - are you using Expound 0.4.0?

@arichiardi
Copy link
Contributor Author

I have tried again and cannot reproduce the original error I tried yours and it is working. I am using s/check-asserts but it works the same. I will try to observe the situation, we can close this for now and reopen it later. I will try to be more careful and don't create too much noise next time...

@bhb
Copy link
Owner

bhb commented Feb 4, 2018

@arichiardi Yes, if you see this again, please don't hesitate to reopen this issue. I'd love to get this fixed. Thanks for using Expound!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants