aphyr / dom-top

Unorthodox control flow, for Clojurists with masochistic sensibilities.
Eclipse Public License 1.0
202 stars 8 forks source link

clj-kondo hook for `loopr` #4

Open walterl opened 1 year ago

walterl commented 1 year ago

There's a clj-kondo analyze-call hook I created for your excellent loopr macro, here.

Apparently libraries can export clj-kondo configs, but unfortunately I don't have the time to wrap this up in a nice PR right now.

jeroenvandijk commented 1 year ago

Indeed very useful library. I found an unexpected scenario that might be suitable for a clj-kondo check maybe.

In the example below shadowing m leads to unexpected result. I would expect that the shadowing would not affect the "for"-like binding part. So if the below is not a bug, maybe clj-kondo could help.

(let [m {:a 1}]
  (loopr [m {}]
         [[k v] m]
         (recur (assoc m k v)))) ;=> {}

(let [m {:a 1}]
  (loopr [m0 {}]
         [[k v] m]
         (recur (assoc m0 k v)))) ;=> {:a 1}