This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-20
Channels
- # adventofcode (140)
- # beginners (107)
- # boot (120)
- # boot-dev (1)
- # clara (13)
- # cljs-dev (9)
- # clojure (107)
- # clojure-argentina (5)
- # clojure-art (16)
- # clojure-dev (23)
- # clojure-greece (19)
- # clojure-italy (5)
- # clojure-russia (2)
- # clojure-serbia (3)
- # clojure-spec (27)
- # clojure-sweden (1)
- # clojure-uk (15)
- # clojurescript (134)
- # cursive (5)
- # data-science (10)
- # datomic (23)
- # duct (28)
- # fulcro (48)
- # garden (5)
- # hoplon (2)
- # instaparse (1)
- # klipse (7)
- # leiningen (8)
- # lumo (36)
- # off-topic (72)
- # om (4)
- # onyx (37)
- # perun (4)
- # re-frame (64)
- # reagent (86)
- # remote-jobs (1)
- # shadow-cljs (59)
- # spacemacs (16)
- # sql (1)
- # uncomplicate (6)
- # unrepl (90)
If I want to have a macro that will be able to process spec forms defined in ClojureScript, how do I get the forms in the macro definition? s/form
will only get the form at run time, and I need it at compile time.
No, after s/def
. Basically trying to auto-generate destructuring forms based on the spec.
Can someone give me an insight to the issue I'm having with our project please.
Because of the way how clojure.spec.alpha interacts with clojure.test.check, specifically I'm guessing this part https://github.com/clojure/spec.alpha/blob/master/src/main/clojure/clojure/spec/gen/alpha.clj#L38
it breaks on attempt to use clojure.tools.namespace.repl/refresh
, in a project where clojure.test.check.generators
being used in .cljc file(s).
And that's because Generator
record gets redefined, resulting in two different classes.
Here's a sample repo that repros that bug (created by my colleague) https://github.com/xiongtx/reload-error-boot.
I thought the easy way of fixing it is to stop using clojure.test.check
and just use clojure.spec.gen.alpha
everywhere. But that doesn't seem to include bunch of things: macros like gen/let
and gen/bind
, gen/return
, gen/pos-int
, etc. Basically not using it at all - seems not possible (?)
Because of that, CIDER's refresh and clojure.tools.namespace.repl/refrsh
are broken, that makes it sort of painful to work with. Can someone suggest a workaround?
can you use refresh-all
instead?
wait why does Generator
get redefined at all?
refresh
shouldn't be reloading library code
can you please take a look at https://github.com/xiongtx/reload-error-boot there's something strange going on, I think this deserves to be a JIRA ticket (unless someone already filed one) I can't formulate though exactly what's happening
at a glance, my guess is that cider is more enthusiastic about reloading things than tools.namespace is? certainly seems like bad behavior. I don't think tools should reload libraries under normal circumstances. I've never seen tools.namespace do that.
it's because of this https://github.com/clojure/spec.alpha/blob/master/src/main/clojure/clojure/spec/gen/alpha.clj#L38
you're saying the lack of a standard require makes tools.namespace act as if t.c.generators was a project namespace?
does tools.namespace explicitly announce that it's reloading the generators namespace?
(it usually prints which things it's reloading)
this is in our project, when you do (require '[clojure.tools.namespace.repl :refer [refresh]]) (refresh)
:reloading ... then list of namespaces
:error-while-loading finops-admin.specs.shared
#error {
:cause "Assert failed: Second arg to such-that must be a generator\n(generator? gen)"
:via
[{:type clojure.lang.Compiler$CompilerException
:message "java.lang.AssertionError: Assert failed: Second arg to such-that must be a generator\n(generator? gen), compiling:(shared.cljc:72:34)"
:at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3700]}
{:type java.lang.AssertionError
:message "Assert failed: Second arg to such-that must be a generator\n(generator? gen)"
:at [clojure.test.check.generators$such_that invokeStatic "generators.cljc" 346]}]
:trace
and long stacktrace
this is a bug that appears in the .cljc code that's trying to use clojure.test.check.generators
if you read the readme in https://github.com/xiongtx/reload-error-boot you'll see detailed explanation
But does the list of namespaces you elided contain test.check?
okay, that is what seems buggy to me
posted here https://www.reddit.com/r/Clojure/comments/7lbplj/clojuretoolsnamespacereplrefresh_tumbles_on_cljc/
Seems that this is a known issue w/ tools.namespace
. Thanks to @U09LZR36F for pointing this out! https://dev.clojure.org/jira/browse/TNS-45?actionOrder=desc#issue-tabs