clj-kondo

https://github.com/clj-kondo/clj-kondo
serioga 2020-06-08T16:26:33.364900Z

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

borkdude 2020-06-08T16:27:50.365200Z

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

serioga 2020-06-08T16:29:57.366Z

where does it take arity info? parses defn itself?

borkdude 2020-06-08T16:30:57.366200Z

yes

borkdude 2020-06-08T16:32:01.366500Z

but it's probably better to give priority to arglists

borkdude 2020-06-08T16:32:16.366700Z

although I'm not entirely sure

serioga 2020-06-08T16:38:59.367300Z

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

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

borkdude 2020-06-08T17:43:58.368Z

@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

serioga 2020-06-08T17:44:53.368500Z

¯\(ツ)

borkdude 2020-06-08T17:46:03.368900Z

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

serioga 2020-06-08T17:53:47.370900Z

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

serioga 2020-06-08T17:58:41.371900Z

no, we cannot

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

serioga 2020-06-08T17:59:35.372500Z

so comp produce function with same arity as a rightmost one

borkdude 2020-06-08T18:01:35.372700Z

ah right.