Fork me on GitHub
#lsp
<
2024-04-26
>
snoe18:04:39

Has there been any discussion about a full project (like public unused) linter to catch redefs of multimethods across namespaces? I just ran into a bug where two namespaces extended the same dispatch value and our CI loaded one first and dev env loaded the other first. It would be nice to mark both defmethodas ambiguous.

(ns my.common)

(defmulti test-dispatch identity)

(ns my.a (:require [my.common]))

(defmethod my.common/test-dispatch :foo
  [_]
  (println "in a"))

(ns my.b (:require [my.common]))

(defmethod my.common/test-dispatch :foo
  [_]
  (println "in b"))

(ns my.c (:require [my.common]))

(my.common/test-dispatch :foo)

snoe18:04:29

It's probable this should be ignored in test namespaces, but I struggle to find a reason to do so in src.

aisamu21:04:25

(you might want to cross-post this to #clj-kondo)

ericdallo17:04:41

Yeah, although this is a more project related linter, there are already linters in kondo that consider it's cache (project linted files), so I think would behave similar