anyone have a kondo config (or I guess is it even possible) to mark usages of "recur" as an error?
$ 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: 1although recur is technically not a var, this works intentionally
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
(recur) should only be flagged if it's eval'd on it own. 😉
(lazy-seq (recur))
I guess (delay (recur)) must work too
Might need to add these cases to Kondo 😉
What should the message be?
"don't be clever"
"You might want to consider a different career."
just *sigh*
😉
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