Fork me on GitHub
#cljs-dev
<
2016-07-20
>
martinklepsch13:07:00

(defn x [{:keys [extract]
          :or {extract #"\w"}}])
This throws ERROR: Not supported: class java.util.regex.Pattern for me. Works if s/defn/fn.

martinklepsch13:07:12

@anmonteiro: can reproduce with CLJS master

anmonteiro13:07:43

this is definitely related to writing the analysis cache with Transit

anmonteiro13:07:37

relevant piece of the stacktrace:

Caused by: java.lang.RuntimeException: java.lang.Exception: Not supported: class java.util.regex.Pattern
	at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:129)
	at cognitect.transit$write.invokeStatic(transit.clj:149)
	at cognitect.transit$write.invoke(transit.clj:146)
	at cljs.analyzer$write_analysis_cache.invokeStatic(analyzer.cljc:2956)
	at cljs.analyzer$write_analysis_cache.invoke(analyzer.cljc:2943)
	at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1283)
	at cljs.compiler$emit_source.invoke(compiler.cljc:1232)
	at cljs.compiler$compile_file_STAR_$fn__3646.invoke(compiler.cljc:1304)
	at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1154)
	at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1145)
	at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1293)

rohit17:07:11

@martinklepsch, @anmonteiro: yup. i can reproduce the issue as well and I agree that its related to the analysis cache with Transit.

rohit18:07:02

I’ve got a patch which can be applied to master which should fix the issue.

rohit18:07:29

@martinklepsch: could you confirm if this fixes your issue?

rohit18:07:03

looking at the code for edn - surprising thing is that the .edn file has a regex in it, even though a regex is not valid edn afaik.

martinklepsch18:07:31

@rohit: your patch seems to work 👍

rohit19:07:25

@martinklepsch: sweet. a larger issue is if there should be regex in the cache file. i don’t know the answer to that

rohit19:07:46

so basically the compiler spits out a regex for edn/transit.

rohit19:07:55

with the patch, transit can read/write a regex

rohit19:07:02

but edn one can only write a regex as it uses pr-str but it can’t read a regex

rohit19:07:15

as regex isn’t valid edn