dom-top icon indicating copy to clipboard operation
dom-top copied to clipboard

clj-kondo hook for `loopr`

Open walterl opened this issue 3 years ago • 1 comments

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.

walterl avatar Sep 11 '22 08:09 walterl

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}

jeroenvandijk avatar Feb 13 '23 15:02 jeroenvandijk