clj-kondo 2026-04-22

anyone have a kondo config (or I guess is it even possible) to mark usages of "recur" as an error?

👀 1

$ clj-kondo --config '{:linters {:discouraged-var {clojure.core/recur {:message "no recur"}}}}' --lint - <<< '(defn foo [] (recur))'
<stdin>:1:14: warning: no recur
linting took 43ms, errors: 0, warnings: 1

although recur is technically not a var, this works intentionally

🙌 1

curious why you would want to use this though

we just had an issue with a run away loop, so possible guard rails around that in the future would be in certain projects, where all loops should be bounded anyway, flag using recur as an error, so at the very least loops will be bound by stack space

(I mean, as long as no one decides to use trampoline)

you can flag that one too ;)

what naughtiness is this

fogus (Clojure Team) 2026-04-22T19:41:49.402249Z

(recur) should only be flagged if it's eval'd on it own. 😉

I guess (delay (recur)) must work too

fogus (Clojure Team) 2026-04-22T20:00:35.458199Z

Might need to add these cases to Kondo 😉

What should the message be?

"don't be clever"

fogus (Clojure Team) 2026-04-22T20:08:35.371919Z

"You might want to consider a different career."

😆 2

just *sigh*

☝️ 2

😉

user=> (def d (let [x true] (delay (assert x) @d)))
#'user/d
user=> @d
Execution error (AssertionError) at user/fn$fn (REPL:1).
Assert failed: x