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

error in clojurescript #3

Closed
pbrito opened this issue Jul 16, 2017 · 10 comments
Closed

error in clojurescript #3

pbrito opened this issue Jul 16, 2017 · 10 comments

Comments

@pbrito
Copy link

pbrito commented Jul 16, 2017

Hi,
I'm beginning to use spec with clojurescript.
But I can't use this library.
s/explain works but not expound

cljs.user=> (expound/expound :example/place {})

#object[TypeError TypeError: Cannot read property 'cljs$lang$applyTo' of undefined]
TypeError: Cannot read property 'cljs$lang$applyTo' of undefined
@bhb
Copy link
Owner

bhb commented Jul 16, 2017

Thanks for reporting this bug!

In order to help me track down the problem, can you please let me know:

  1. Your version of Clojure
  2. Your version of Clojurescript
  3. Your version of org.clojure/spec.alpha (if any)
  4. The 'require' statement for expound.

Thanks!

@pbrito
Copy link
Author

pbrito commented Jul 16, 2017

I run the project with 'rlwrap lein figwheel'

lein -v                                                                                                                                                              
Leiningen 2.7.1 on Java 1.8.0_45 Java HotSpot(TM) 64-Bit Server VM

Dependencies in project.clj

  :dependencies [ [org.clojure/clojure "1.9.0-alpha12"]
                  [org.clojure/clojurescript "1.9.671"]
                  [expound "0.1.0"]]

  :plugins [[lein-figwheel "0.5.8"]]

In the repl I do
(require '[cljs.spec.alpha :as s])
instead of
(require '[clojure.spec.alpha :as s])

So when I use spec it goes well:

hello.core=> (s/explain :example/place {})
val: {} fails spec: :example/place predicate: (contains? % :city)
val: {} fails spec: :example/place predicate: (contains? % :state)
:cljs.spec.alpha/spec  :example/place
:cljs.spec.alpha/value  {}

But expound

hello.core=> (expound/expound :example/place {})
#object[TypeError TypeError: Cannot read property 'cljs$lang$applyTo' of undefined]
TypeError: Cannot read property 'cljs$lang$applyTo' of undefined
    at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$3 (file:///Users/paulo/clojure/spec-cljs/out/cljs/core.js:12870:5)
    at cljs$core$apply (file:/

@bhb
Copy link
Owner

bhb commented Jul 17, 2017

Thanks for the details! I am having trouble getting lein-figwheel 0.5.8 to work, but I can reproduce with that version of Clojure, Clojurescript and figwheel 0.5.11. I'm not sure what's going on - there seems to be some change in recent versions of Clojurescript where goog.string is not being loaded properly. I don't see the same problem on Clojurescript 1.9.542, but I realize that's not a great workaround. I'll see if I can figure out the issue tomorrow.

@bhb
Copy link
Owner

bhb commented Jul 17, 2017

I think I may have discovered a fix. Can you try the following:

  1. Clone this repo
  2. cd into the main dir
  3. lein install
  4. In your test project's project.clj, change [expound "0.1.0"]] to [expound "0.1.1-SNAPSHOT"]]
  5. Let me know if it is fixed :)

@pbrito
Copy link
Author

pbrito commented Jul 17, 2017

error:
Could not find artifact expound:expound:jar:0.1.1-SNAPSHOT in clojars

@bhb
Copy link
Owner

bhb commented Jul 17, 2017

@pbrito That's correct: I haven't yet pushed it to Clojars. However, the lein install step should install it for you locally (once you have pulled down this repo). Did you get any errors when running lein install?

@pbrito
Copy link
Author

pbrito commented Jul 17, 2017

Sorry! I didn't follow your instruction.

So, after following your instructions, I was able compiled without errors:

Wrote /Users/paulo/clojure/specT/expound/pom.xml
Installed jar and pom into local repo.

And using expound "0.1.1-SNAPSHOT" in my project returned:

dev:hello.core=> (expound/expound :example/place {})
-- Spec failed --------------------

  {}

should contain keys: `:city`,`:state`

-- Relevant specs -------

:example/place:
  (cljs.spec.alpha/keys
   :req-un
   [:example.place/city :example.place/state])

-------------------------
Detected 1 error

My project dependencies

  :dependencies [ [org.clojure/clojure "1.9.0-alpha12"]
                  [org.clojure/clojurescript "1.9.542"]
                  [expound "0.1.1-SNAPSHOT"]
                  ;[org.clojure/test.check "0.10.0-alpha2"]]

  :plugins [[lein-figwheel "0.5.11"]]

@bhb
Copy link
Owner

bhb commented Jul 17, 2017

@pbrito Thanks very much for confirming the fix! I'll release a new version with this fix sometime tonight.

@bhb
Copy link
Owner

bhb commented Jul 18, 2017

Fixed with 131d86c

@bhb bhb closed this as completed Jul 18, 2017
@bhb
Copy link
Owner

bhb commented Jul 18, 2017

@pbrito Should be fixed in version [expound "0.1.1"] (now on Clojars). Thanks for the bug report!

@vemv vemv mentioned this issue Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants