自从Om `1.9.293`以来,我在编译过程中遇到了一些问题,我能够将其缩小到以下代码
(defn f [{:keys [a] :or {a #js {}}}])
上面的代码在添加了项目依赖库[com.cognitect/transit-clj "0.8.290"]后无法编译。问题似乎出现在我们尝试在函数参数中解构数据时,使用`:or`并且`:or`部分有`#js`。
我在这里创建了一个包含最小化案例的仓库:
https://github.com/wilkerlucio/cljs-compilation-fail
编译时的错误堆栈
Wilkers-MacBook-Pro:cljs-compile-bug wilkerlucio$ lein clean && lein cljsbuild once site
正在编译ClojureScript...
正在编译"resources/public/site/site.js",来源为["src"]...
编译"resources/public/site/site.js"失败。
clojure.lang.ExceptionInfo: 编译文件失败:src/cljs_compile_bug/core.cljs {:file #object[java.io.File 0x21399e53 "src/cljs_compile_bug/core.cljs"]}
at clojure.core$ex_info.invokeStatic(core.clj:4725)
at clojure.core$ex_info.invoke(core.clj:4725)
at cljs.compiler$compile_file$fn__4104.invoke(compiler.cljc:1410)
at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1376)
at cljs.compiler$compile_file.invoke(compiler.cljc:1356)
at cljs.closure$compile_file.invokeStatic(closure.clj:432)
at cljs.closure$compile_file.invoke(closure.clj:423)
at cljs.closure$eval6005$fn__6006.invoke(closure.clj:499)
at cljs.closure$eval5941$fn__5942$G__5930__5949.invoke(closure.clj:389)
at cljs.closure$compile_task$fn__6096.invoke(closure.clj:779)
at cljs.closure$compile_task.invokeStatic(closure.clj:777)
at cljs.closure$compile_task.invoke(closure.clj:770)
at cljs.closure$parallel_compile_sources$fn__6102.invoke(closure.clj:806)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1963)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1963)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at cljs.closure$eval5940$fn__5941$G__5930__5936.invoke(closure.clj:389)
at cljs.closure$compile_task$fn__6096.invoke(closure.clj:779)
at cljs.closure$compile_task.invokeStatic(closure.clj:777)
at cljs.closure$compile_task.invoke(closure.clj:770)
at cljs.closure$parallel_compile_sources$fn__6102.invoke(closure.clj:806)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:657)
错误原因:java.lang.RuntimeException: clojure.lang.ArityException: 将错误数量的参数(1)传递给:analyzer/fn--1412/fn--1413
at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:64)
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:3320)
at cljs.analyzer$write_analysis_cache.invoke(analyzer.cljc:3307)
at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1307)
at cljs.compiler$emit_source.invoke(compiler.cljc:1237)
at cljs.compiler$compile_file_STAR_$fn__4081.invoke(compiler.cljc:1328)
at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1159)
at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1150)
at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1317)
at cljs.compiler$compile_file_STAR_.invoke(compiler.cljc:1313)
at cljs.compiler$compile_file$fn__4104.invoke(compiler.cljc:1398)
... 25 更多
错误原因:clojure.lang.ArityException: 将错误数量的参数(1)传递给:analyzer/fn--1412/fn--1413
at clojure.lang.AFn.throwArity(AFn.java:429)
at clojure.lang.AFn.invoke(AFn.java:32)
at cognitect.transit$write_handler$reify__1328.tag(transit.clj:79)
at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:147)
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:61)
... 37 更多
子进程失败