technomancy/slamhound

Gets confused with functions of the same name in different ns's

kenrestivo opened this issue · 3 comments

foo.clj

 (ns foo) 
(defn bar [] ...)

baz.clj

(ns baz)
(defn bar [] 
   (f/bar) 
    ...)

Slamhound does this:

(ns baz
 (require (baz :as f))

So I get (ns baz (:require baz :as f)), which is weird, instead of (ns baz (:require (foo :as f)). It also causes some really fun stackoverflow errors.

I guess it saw that there was a bar in this ns, and thought that's what I wanted.

I hacked around this by just changing the name of foo/bar to foo/bar2.

Stil bumping into this.

It would be great if there were a way to override slamhound. To tell it, no, I really DO mean what I wrote in the NS, don't delete it and put something wrong in there.

The latest problem is if I have a var foo/settings, and bar/settings and I really do want those to be separate, slamhound will confuse them and use only foo/settings and there's no way to distinguish them.

It's quite common to use namespaces to have the same var in different ns'es, that's kind of the whole point. If I have to write code like (ns foo) (def foo-settings ...) and (ns bar) (def bar-settings), just so that slamhound doesn't stomp on my requires, that seems a bit silly.

To tell it, no, I really DO mean what I wrote in the NS, don't delete it and put something wrong in there.

Last I checked this was how it was supposed to function; it should keep around the original mapping and prefer it. Searching for a var in a different namespace should only happen if it's not in the original map. So this is definitely a bug.

#41 looks like it'll fix it, thanks!