Fork me on GitHub
#clj-kondo
<
2020-06-08
>
serioga16:06:33

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}})

borkdude16:06:50

issue is welcome. currently clj-kondo doesn't look at arglists

serioga16:06:57

where does it take arity info? parses defn itself?

borkdude16:06:01

but it's probably better to give priority to arglists

borkdude16:06:16

although I'm not entirely sure

serioga16:06:59

> although I'm not entirely sure the questionable case I see like

(defn my-function
  {:arglists '([{:keys [a b c]}])}
  [data])

borkdude17:06:58

@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

serioga17:06:53

¯\(ツ)

borkdude17:06:03

alternatively we could deduce that comp always returns an arity-1 function

serioga17:06:47

well, it you can analyze if def is a anonymous function and use its arity — it also would be cool

serioga17:06:41

no, we cannot

((comp identity +) 1 2)
=> 3

serioga17:06:35

so comp produce function with same arity as a rightmost one