clj-kondo

a13 2026-01-13T09:36:21.366219Z

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?

borkdude 2026-01-13T09:42:29.165239Z

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?

πŸ‘€ 1
a13 2026-01-13T09:42:51.199109Z

btw, a map or a lambda work just fine

borkdude 2026-01-13T09:43:10.522579Z

yeah I think the issue is that comp has a return type, but it's nil or something

a13 2026-01-13T09:45:13.310239Z

partial works too

borkdude 2026-01-13T09:46:13.574519Z

ah wait, this should be :ifn

(identical? matcher-type :fn)

a13 2026-01-13T09:46:28.676409Z

or both?

borkdude 2026-01-13T09:46:29.783879Z

I got it @tomd

πŸ‘ 1
borkdude 2026-01-13T09:47:00.481579Z

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)
                                  

borkdude 2026-01-13T09:47:33.462269Z

I guess we could tighten the return type of comp to :fn

borkdude 2026-01-13T09:48:22.390719Z

not sure what the comment was exactly about but I think we should do both: tighten comp to fn and allow ifn here

tomd 2026-01-13T09:48:34.321769Z

agreed πŸ‘

borkdude 2026-01-13T10:28:47.467909Z

https://github.com/clj-kondo/clj-kondo/pull/2731/files

πŸ‘ 1
πŸš€ 1
a13 2026-01-13T10:29:10.547239Z

Thanks!

2026-01-13T14:00:08.775069Z

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.

borkdude 2026-01-13T14:01:20.229949Z

so when fn is defn it is redundant?

2026-01-13T14:01:42.014769Z

yes

borkdude 2026-01-13T14:01:59.571009Z

hmm

borkdude 2026-01-13T14:02:21.623009Z

PR welcome to fix it :)

borkdude 2026-01-13T14:02:41.763299Z

(both in Clojure and in clj-kondo, but I can only merge the latter :P)

2026-01-13T14:04:21.625389Z

What’s the best path for the former?

borkdude 2026-01-13T14:04:58.910069Z

the former? I guess discuss in #clojure-dev first, then http://ask.clojure.org, then JIRA, then patch

βž• 1