I have a false positive when using comp as a replacement for clojure.string/replace
dk@darkhorizon:~$ clj-kondo --lint - <<< '(ns foo (:require [clojure.string :as str])) (str/replace "$a" #"\w+" (comp str))'
<stdin>:1:71: error: Regex match arg requires string or function replacement arg.
linting took 10ms, errors: 1, warnings: 0
dk@darkhorizon:~$ clj-kondo --version
clj-kondo v2026.01.12
Since something like this was fixed https://github.com/borkdude/clj-kondo/issues/795, perhaps a regression bug?hmm, this might be because of the incomplete spec here: https://github.com/clj-kondo/clj-kondo/blob/1c45bd4834efec155d59505b0c7af76fdecbac26/src/clj_kondo/impl/types/clojure/core.clj#L536 Something you want to take a look at @tomd?
btw, a map or a lambda work just fine
yeah I think the issue is that comp has a return type, but it's nil or something
partial works too
ah wait, this should be :ifn
(identical? matcher-type :fn)or both?
oh look, a comment here:
;; we could allow :ifn here, but keywords are
;; not valid in this position, so we do an
;; additional check for :map
(identical? matcher-type :fn)
I guess we could tighten the return type of comp to :fn
not sure what the comment was exactly about but I think we should do both: tighten comp to fn and allow ifn here
agreed π
https://github.com/clj-kondo/clj-kondo/pull/2731/files
Thanks!
I have a false positive for :redundant-primitive-coercion , when using an anonymous function.
(let [f (fn ^double [] 1.0)]
(double (f))
clojure does not invoke this through the primitive interface, so the double is required.
It is interesting though, as one might expect the primitive interface to be used.so when fn is defn it is redundant?
yes
hmm
PR welcome to fix it :)
(both in Clojure and in clj-kondo, but I can only merge the latter :P)
Whatβs the best path for the former?
the former? I guess discuss in #clojure-dev first, then http://ask.clojure.org, then JIRA, then patch
https://ask.clojure.org/index.php/14888/invoking-anonymous-primitive-function-primitive-interface