core-async

shaunlebron 2025-11-26T22:11:44.900769Z

Is this a bug?

(go (letfn [(foo [])]
      (
Assert failed:

ghadi 2025-11-26T22:13:57.131489Z

the fns inside letfn are new fn scopes, and go only rewrites the immediate fn scope

ghadi 2025-11-26T22:16:15.337589Z

...so it's fairly accurate

shaunlebron 2025-11-26T22:27:52.056009Z

maybe I don’t know how letfn works, but is not inside a function, right?

2025-11-26T22:52:37.137749Z

Sure looks like a bug to me

seancorfield 2025-11-26T22:53:24.101149Z

Which version of core.async @shaunlebron?

> clj
Clojure 1.12.3
user=> (add-lib 'org.clojure/core.async)
[org.clojure/core.async org.clojure/core.cache org.clojure/core.memoize org.clojure/data.priority-map org.clojure/tools.analyzer org.clojure/tools.analyzer.jvm org.clojure/tools.reader org.ow2.asm/asm]
user=> (require '[clojure.core.async :refer [go <! timeout]])
nil
user=> (go (letfn [(foo [])] (<! (timeout 10))))
#object[clojure.core.async.impl.channels.ManyToManyChannel 0xae73c80 "clojure.core.async.impl.channels.ManyToManyChannel@ae73c80"]
How did you get that error exactly?

shaunlebron 2025-11-26T22:54:10.145939Z

[org.clojure/clojure "1.12.1"]
                 [org.clojure/core.async "1.8.741"]

seancorfield 2025-11-26T22:56:19.690209Z

I can repro with 1.8.741 but not with the most recent version.

shaunlebron 2025-11-26T22:57:09.039259Z

I was running it from my repl, in my giant lein project

2025-11-26T22:59:07.941559Z

Looks like maybe missing handling of the :letfn* tools.analyzer ast node

seancorfield 2025-11-26T23:01:00.998199Z

1.9.808-alpha1 shows that error but 1.9.829-alpha2 doesn't, for me.

Alex Miller (Clojure team) 2025-11-26T23:03:27.807239Z

if you're using the latest alpha on a new jvm, then you're running go in a virtual thread, which is not using the go analyzer

Alex Miller (Clojure team) 2025-11-26T23:03:59.289009Z

I'm pretty sure there is a jira for letfn in go

seancorfield 2025-11-26T23:04:54.363839Z

Ah, I'd forgotten that...

ghadi 2025-11-26T23:11:16.917289Z

letfn bindings are new fn contexts, go cannot rewrite through

2025-11-26T23:14:37.570779Z

The op is in the body of the letfn

2025-11-26T23:15:13.824799Z

Not one of fns

ghadi 2025-11-26T23:16:10.280229Z

oh I misread

ghadi 2025-11-26T23:16:17.977969Z

indentation threw me off

seancorfield 2025-11-26T23:17:23.250059Z

(go (letfn [] (<! (timeout 10)))) fails too πŸ™‚

πŸ™ 1
2025-11-26T23:30:51.859319Z

Gobsmacked not to have run into this permutation before

2025-11-26T23:32:34.268099Z

https://clojure.atlassian.net/browse/ASYNC-221

πŸ™ 1
seancorfield 2025-11-27T00:40:07.375319Z

From 2018!!!

shaunlebron 2025-11-27T01:20:53.005189Z

nobody uses letfn lol

shaunlebron 2025-11-27T01:21:47.459539Z

I only started using it recently to reduce the indentation of nested functions, works really well for that

2025-11-27T02:46:12.686009Z

https://github.com/hiredman/clojure/blob/readerIII/src/clj/clojure/reader.clj#L165 letfn and I go back like spinal cords and car seats