2024 年 Clojure 状况调查! 中分享您的想法。

欢迎!请参阅 关于 页面以获取更多关于如何使用本站的信息。

0
core.async

在 go-loop 或带循环的 go 块内部进行类型提示会导致类型提示信息丢失。看起来必须从通道中读取数据才能丢失。

`
user=> (require ['clojure.core.async :as 'async])
nil
user=> (import 'java.util.Date)
java.util.Date
user=> (set! warn-on-reflection true)
true
user=> (let [a [(Date.) (Date.)] #_=> ch (async/chan)]
#=> (async/go-loop []
#
=> (when (async/<! ch)
#=> (println (.getDate ^Date (get a 0)))
#
=> (recur))))
反射警告,/tmp/form-init7283017118477479525.clj:3:3 - 无法解决的字段getDate的引用。

object[clojure.core.async.impl.channels.ManyToManyChannel 0x2572eb4e "clojure.core.async.impl.channels.ManyToManyChannel@2572eb4e"]

user=> (let [a [(Date.) (Date.)] #_=> ch (async/chan)]
#=> (async/go-loop []
#
=> (when (async/<! ch)
#_=> (println (.getDate ^Date (get a 0))))))

object[clojure.core.async.impl.channels.ManyToManyChannel 0x12e8b6a3 "clojure.core.async.impl.channels.ManyToManyChannel@12e8b6a3"]

user=> (let [a [(Date.) (Date.)]]
#=> (async/go-loop []
#
=> (println (.getDate ^Date (get a 0)))
#=> (throw (Exception. "repl abort"))
#
=> (recur)))
12

object[clojure.core.async.impl.channels.ManyToManyChannel 0x1b48111e "clojure.core.async.impl.channels.ManyToManyChannel@1b48111e"]

异常在 "async-dispatch-1" 线程中:java.lang.Error: java.lang.Exception: repl abort

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

由:java.lang.Exception: repl abort

at user$eval1611$fn__1618$state_machine__6321__auto____1621$fn__1623$fn__1625.invoke(form-init7283017118477479525.clj:3)
at user$eval1611$fn__1618$state_machine__6321__auto____1621$fn__1623.invoke(form-init7283017118477479525.clj:2)
at user$eval1611$fn__1618$state_machine__6321__auto____1621.invoke(form-init7283017118477479525.clj:2)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:975)
at user$eval1611$fn__1618.invoke(form-init7283017118477479525.clj:2)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
... 2 more

`

1 答案

0
参考: https://clojure.atlassian.net/browse/ASYNC-207(由 wickedshell 报告)
...