This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-16
Channels
- # beginners (7)
- # cider (128)
- # clara (9)
- # clojure (7)
- # clojure-norway (3)
- # clojure-spec (2)
- # clojure-uk (16)
- # clojurescript (79)
- # css (1)
- # datomic (2)
- # devcards (1)
- # editors (39)
- # euroclojure (4)
- # events (1)
- # figwheel (25)
- # fulcro (1)
- # luminus (3)
- # off-topic (15)
- # om (3)
- # onyx (10)
- # protorepl (8)
- # reagent (5)
- # reitit (1)
- # shadow-cljs (95)
- # tools-deps (6)
@thheller I found a nasty issue with shadow + lein + cljs 1.10.312
I can't use test.check generators with this combined settings
there was some changes in dynamic var checking, not sure what exactly, but it keeps complaining that clojure.test.check.generators
is not loaded, but it is
using just shadow without lein works fine
I just created a minimum repro, I'll open an issue with that
hmm lein
basically only constructs the classpath. are you sure there aren't any classpath issues?
the repro is really simple, I can't see how that would be
unless I'm blind and missing something, can you take a look?
just preparing the repro to upload, one min
here I get this with this code:
alpha.cljs:70 Uncaught Error: Var clojure.test.check.generators/return does not exist, clojure.test.check.generators never required
at alpha.cljs:70
at cljs.spec.gen.alpha.LazyVar.cljs$core$IDeref$_deref$arity$1 (alpha.cljs:22)
at Object.cljs$core$_deref [as _deref] (core.cljs:673)
at Object.cljs$core$deref [as deref] (core.cljs:1449)
at Function.cljs$core$IFn$_invoke$arity$variadic (alpha.cljs:70)
at alpha.cljs:91
at cljs.core.Delay.cljs$core$IDeref$_deref$arity$1 (core.cljs:10369)
at Object.cljs$core$_deref [as _deref] (core.cljs:673)
at Object.cljs$core$deref [as deref] (core.cljs:1449)
at Object.cljs$spec$gen$alpha$gen_for_pred [as gen_for_pred] (alpha.cljs:148)
strange, when I replace :lein true
with:
:source-paths ["src"]
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.312"]
[org.clojure/test.check "0.9.0"]
[thheller/shadow-cljs "2.4.5"]]
it works here
ah, gotcha, and how do you force shadow to use a different version?
yeah, but compiling with pure cljs main things, it works
so I guess there is something getting off
this can be a problem to bump shadow, anyone using generators will be affected
when I was trying to debug in #clojurescript yesterday david said this: https://clojurians.slack.com/archives/C03S1L9DN/p1529073112000560
ring any bells?
I can send you a repo ready here
deps.edn
{:paths ["src"]
:deps {org.clojure/clojurescript {:mvn/version "1.10.312"}
org.clojure/test.check {:mvn/version "0.9.0"}}}
I tried here, seems the name is clojure.test.check.generators.return$
as you said
and we though cljs would come with no surprises 😛
if((((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined') && (typeof clojure.test.check.quick_check !== 'undefined')))){
((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined'))
is tested twice
if((((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined') && (typeof clojure.test.check.generators !== 'undefined') && (typeof clojure.test.check.generators["return"] !== 'undefined')))){
just curious now, how do you find the compiled code? there is a way in chrome to go from source mapped to compiled source?
just open the file in the editor. just searched for the never required
error and went from there
ok, more a brute force thing 🙂
ok the exists?
thing is definitely weird and messes with how shadow-cljs handles js/stuff
haha the cljs.spec.gen.alpha/dynaload
macro does the work that the new exists?
macro does. thats why the check is done twice
(and [email protected] (c/exists? ~s))
seems like it
is that some shadow hack that is not going well with the new exists?
?
https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/cljs_hacks.cljc#L448-L468
basically the problem is that clojure.test.check.generators/return
gets turned into clojure.test.check.generators.return$
but js/clojure.test.check.generators.return
is turned into clojure.test.check.generators["return"]
JS code in npm doesn't munge .return
or so but the CLJS compiler does when you try to access it
I was reading the commits, seems like it was to fix some self-hosting thing
so that might be way they keep touching on JS, since it's all self-hosting have access too
https://github.com/clojure/clojurescript/commit/9f8ad161eda1eb4b0fdb782e593ee9400b4e1f96
(core/defmacro exists?
"Return true if argument exists, analogous to usage of typeof operator
in JavaScript."
[x]
(if (core/symbol? x)
(core/let [x (core/cond-> (:name (cljs.analyzer/resolve-var &env x))
(= "js" (namespace x)) name)
segs (string/split (core/str (string/replace (core/str x) "/" ".")) #"\.")
n (count segs)
syms (map
#(vary-meta (symbol "js" (string/join "." %))
assoc :cljs.analyzer/no-resolve true)
(reverse (take n (iterate butlast segs))))
js (string/join " && " (repeat n "(typeof ~{} !== 'undefined')"))]
(bool-expr (concat (core/list 'js* js) syms)))
`(some? ~x)))
if I change it to
(core/defmacro exists?
"Return true if argument exists, analogous to usage of typeof operator
in JavaScript."
[x]
(if (core/symbol? x)
(core/let [x (core/cond-> (:name (cljs.analyzer/resolve-var &env x))
(= "js" (namespace x)) name)
segs (string/split (core/str (string/replace (core/str x) "/" ".")) #"\.")
n (count segs)
syms (map
#(vary-meta (symbol (string/join "." %))
assoc :cljs.analyzer/no-resolve true)
(reverse (take n (iterate butlast segs))))
js (string/join " && " (repeat n "(typeof ~{} !== 'undefined')"))]
(bool-expr (concat (core/list 'js* js) syms)))
`(some? ~x)))
I really need to learn cljs.main
. someone should verify that the exists?
calls not actually generate externs via externs inference. I think they might.
maybe we should bring that to #cljs-dev ?
whys that?
(exists? cljs.core/return)
"(typeof cljs.user.cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.return$ !== 'undefined')"
seems like the cljs.analyzer/no-resolve
is ignored for some reason and js/
is just an easy way to force it to not resolve
thanks for checking it out