clj-kondo

2026-04-22T17:35:44.804089Z

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

👀 1
borkdude 2026-04-22T17:43:50.927909Z

$ 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

borkdude 2026-04-22T17:44:04.485959Z

although recur is technically not a var, this works intentionally

🙌 1
borkdude 2026-04-22T17:44:51.417059Z

curious why you would want to use this though

2026-04-22T17:46:38.503649Z

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

2026-04-22T17:48:29.404939Z

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

borkdude 2026-04-22T17:48:38.771079Z

you can flag that one too ;)

2026-04-22T18:46:35.261769Z

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. 😉

2026-04-22T19:50:52.031259Z

(lazy-seq (recur))

2026-04-22T19:51:09.007109Z

I guess (delay (recur)) must work too

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

Might need to add these cases to Kondo 😉

borkdude 2026-04-22T20:06:04.022479Z

What should the message be?

borkdude 2026-04-22T20:08:34.603579Z

"don't be clever"

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

"You might want to consider a different career."

😆 2
2026-04-22T20:11:31.782119Z

just *sigh*

☝️ 2
2026-04-22T20:18:56.350209Z

😉

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