Fork me on GitHub
#clj-kondo
<
2021-01-08
>
delaguardo12:01:08

I found a “problem” with defmethod because defmethod expects & fn-tail it is possible to set local binding for the function that implement that particular method. but clj-kondo give me an error for such case

borkdude12:01:54

@delaguardo Can you post this code as text instead of screenshot?

delaguardo12:01:30

(require '[clojure.string :as string])

(defmulti example :tag)

(defmethod example :node
  f
  ([] "NODE: ")
  ([{:keys [children]}]
   (str (f) (string/join " " (map example children)))))

(defmethod example :leaf
  f
  ([] "LEAF: ")
  ([{:keys [value]}]
   (str (f) value)))
sure

delaguardo12:01:28

this is definitely an edge case which I never saw in real examples so I came here to check if this is something that should be addressed in clj-kondo.

borkdude12:01:21

ah, so multimethods fns can be named. didn't know that So a working example would be:

(prn
 (example {:tag :node :children [{:tag :leaf :value 1}]}))

borkdude12:01:49

it also works with bb :)

$ bb /tmp/mm.clj
"NODE: LEAF: 1"

borkdude12:01:08

Feel free to make an issue about this

borkdude12:01:01

you can ignore the false positive with #_:clj-kondo/ignore (f)