We're updating the issue view to help you get more done. 

Compiler analysis cache issue with regex and Transit

Description

This issue was reported by Martin Klepsch on Slack.

The following code causes the compiler to throw an error if transit-clj is included as a dependency.

core.cljs

1 2 3 4 5 6 (ns hello-world.core) (enable-console-print!) (defn x [{:keys [extract] :or {extract #"\w"}}])

build.clj

1 2 3 (require 'cljs.build.api) (cljs.build.api/build "src" {:output-to "out/main.js"})

I used the following command to compile the code:

1 java -cp cljs.jar:transit-java-0.8.311.jar:transit-clj-0.8.285.jar:src clojure.main build.clj

The error stack trace is:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 Exception in thread "main" clojure.lang.ExceptionInfo: failed compiling file:src/hello_world/core.cljs {:file #object[java.io.File 0xaed0151 "src/hello_world/core.cljs"]}, compiling:(....build.clj:3:1) at clojure.lang.Compiler.load(Compiler.java:7391) at clojure.lang.Compiler.loadFile(Compiler.java:7317) at clojure.main$load_script.invokeStatic(main.clj:275) at clojure.main$script_opt.invokeStatic(main.clj:335) at clojure.main$script_opt.invoke(main.clj:330) at clojure.main$main.invokeStatic(main.clj:421) at clojure.main$main.doInvoke(main.clj:384) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.lang.Var.invoke(Var.java:379) at clojure.lang.AFn.applyToHelper(AFn.java:154) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: clojure.lang.ExceptionInfo: failed compiling file:src/hello_world/core.cljs {:file #object[java.io.File 0xaed0151 "src/hello_world/core.cljs"]} at clojure.core$ex_info.invokeStatic(core.clj:4617) at cljs.compiler$compile_file$fn__2840.invoke(compiler.cljc:1368) at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1338) at cljs.closure$compile_file.invokeStatic(closure.clj:471) at cljs.closure$fn__3897.invokeStatic(closure.clj:538) at cljs.closure$fn__3897.invoke(closure.clj:534) at cljs.closure$fn__3839$G__3832__3846.invoke(closure.clj:430) at cljs.closure$compile_sources$iter__4008__4012$fn__4013.invoke(closure.clj:870) at clojure.lang.LazySeq.sval(LazySeq.java:40) at clojure.lang.LazySeq.seq(LazySeq.java:49) at clojure.lang.Cons.next(Cons.java:39) at clojure.lang.RT.next(RT.java:688) at clojure.core$next__4341.invokeStatic(core.clj:64) at clojure.core$dorun.invokeStatic(core.clj:3033) at clojure.core$doall.invokeStatic(core.clj:3039) at cljs.closure$compile_sources.invokeStatic(closure.clj:867) at cljs.closure$build.invokeStatic(closure.clj:1995) at cljs.build.api$build.invokeStatic(api.clj:209) at cljs.build.api$build.invoke(api.clj:198) at cljs.build.api$build.invokeStatic(api.clj:201) at cljs.build.api$build.invoke(api.clj:198) at user$eval24.invokeStatic(build.clj:3) at user$eval24.invoke(build.clj:3) at clojure.lang.Compiler.eval(Compiler.java:6927) at clojure.lang.Compiler.load(Compiler.java:7379) ... 11 more 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:2871) at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1268) at cljs.compiler$compile_file_STAR_$fn__2817.invoke(compiler.cljc:1287) at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1154) at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1278) at cljs.compiler$compile_file$fn__2840.invoke(compiler.cljc:1358) ... 34 more Caused by: java.lang.Exception: Not supported: class java.util.regex.Pattern at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:176) at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:158) at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:70) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:166) at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:158) at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:70) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:166) at com.cognitect.transit.impl.AbstractEmitter.emitArray(AbstractEmitter.java:82) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:164) at com.cognitect.transit.impl.AbstractEmitter.emitArray(AbstractEmitter.java:87) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:164) at com.cognitect.transit.impl.AbstractEmitter.emitTagged(AbstractEmitter.java:34) at com.cognitect.transit.impl.AbstractEmitter.emitEncoded(AbstractEmitter.java:59) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:169) at com.cognitect.transit.impl.AbstractEmitter.emitArray(AbstractEmitter.java:87) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:164) at com.cognitect.transit.impl.AbstractEmitter.emitTagged(AbstractEmitter.java:34) at com.cognitect.transit.impl.AbstractEmitter.emitEncoded(AbstractEmitter.java:59) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:169) at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:158) at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:70) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:166) at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:158) at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:70) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:166) at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:158) at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:70) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:166) at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:158) at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:70) at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:166) at com.cognitect.transit.impl.AbstractEmitter.marshalTop(AbstractEmitter.java:193) at com.cognitect.transit.impl.JsonEmitter.emit(JsonEmitter.java:28) at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:126) ... 42 more

It works perfectly fine if the transit dependency is removed.

Environment

Mac OS X. Bug reproduced on master branch and latest release

Status

Assignee

Unassigned

Reporter

Rohit Aggarwal

Labels

None

Approval

None

Patch

Code

Affects versions

1.9.76

Priority

Minor