This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-26
Channels
- # beginners (145)
- # boot (19)
- # calva (61)
- # cider (33)
- # cljs-dev (15)
- # cljsrn (16)
- # clojure (35)
- # clojure-dev (39)
- # clojure-russia (2)
- # clojure-spec (10)
- # clojure-uk (7)
- # clojurescript (5)
- # cursive (14)
- # data-science (1)
- # datomic (3)
- # figwheel-main (9)
- # fulcro (46)
- # jobs (4)
- # off-topic (8)
- # quil (6)
- # re-frame (5)
- # shadow-cljs (70)
- # spacemacs (3)
- # speculative (2)
- # tools-deps (2)
hash-map
can’t be instrumented and then called in CLJ but it can be in CLJS.
$ clj -A:test -m cljs.main -re node
ClojureScript 1.10.439
cljs.user=> (require '[speculative.core])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as stest])
nil
cljs.user=> (stest/instrument `hash-map)
[cljs.core/hash-map]
cljs.user=> (apply hash-map [1])
repl:13
throw e__6573__auto__;
^
Error: Call to #'cljs.core/hash-map did not conform to spec.
$ clj -A:test
Clojure 1.10.0
user=> (require '[speculative.core])
nil
user=> (require '[clojure.spec.test.alpha :as stest])
nil
user=> (stest/instrument `hash-map)
[clojure.core/hash-map]
user=> (apply hash-map [1])
Execution error (StackOverflowError) at (REPL:1).
null
I don’t understand why, because this has never been the case before with CLJ. With CLJS these are pretty common, because it has no direct linking.
The cause is probably that spec-checking-fn
calls with-instrument-disabled
, which calls binding
which expands in a call to hash-map
, so there’s a loop.
A possible solution would be to replace in the binding
macro:
(push-thread-bindings (hash-map ~@(var-ize bindings)))
with
(push-thread-bindings (clojure.lang.PersistentHashMap/create ~(var-ize bindings)))
i.e. inline the hash-map
call.
Probably very low priority, but if there’s interest, I’ll make the JIRA ticket.Don’t want to depend on the class like that
If anything would be better to use RT/map or whatever
When I depend on a local version of spec.alpha (not spec-alpha2), I get:
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
clojure.spec.alpha$explain_out
when I call an instrumented function with invalid args. No clue what this is.