Hello @borkdude
Is it realistic to wish that clj-kondo checks function arities using :arglists
meta, like here:
(def ^{:arglists '([x])} my-function (comp :b :a))
(my-function) ; <- warning is wanted here
(my-function {:a {:b 1}})
issue is welcome. currently clj-kondo doesn't look at arglists
where does it take arity info?
parses defn
itself?
yes
but it's probably better to give priority to arglists
although I'm not entirely sure
> although I'm not entirely sure the questionable case I see like
(defn my-function
{:arglists '([{:keys [a b c]}])}
[data])
@serioga arglists often have informal regex syntax like foo*
to indicate multiple foos. that might not make it great for inferencing arity information from it.
https://github.com/clojure/clojure/blob/30a36cbe0ef936e57ddba238b7fa6d58ee1cbdce/src/clj/clojure/core.clj#L5787
¯\(ツ)/¯
alternatively we could deduce that comp
always returns an arity-1 function
well, it you can analyze if def
is a anonymous function and use its arity — it also would be cool
no, we cannot
((comp identity +) 1 2)
=> 3
so comp
produce function with same arity as a rightmost one
ah right.