Fork me on GitHub
#clojure-dev
<
2018-09-05
>
madstap20:09:45

I had an issue where I had two functions in a file, replace-_ and replace_-. This worked in dev, but when I aot the project, any invocation of either is replaced by the last one in the file. I suppose this is because munge gives the same result for both those names. Is this a known issue?

seancorfield20:09:34

"known" as in "there's a JIRA ticket because it's a bug"? or as in "yes, munge produces the same JVM-level name for both because that's just how it works"? 🙂

seancorfield20:09:41

I don't remember anyone specifically mentioning it as a problem -- but I don't know whether the behavior of munge is documented anywhere in a way that would make the possibility of collisions obvious...

seancorfield20:09:44

@madstap I assume your functions are related to converting names between kebab-case and snake_case?

madstap20:09:17

Yeah, exactly

madstap20:09:44

I figure I should at least get a warning or something....

seancorfield20:09:24

Yeah, I'd say it's worth opening a JIRA ticket to add a compilation warning about name-munging producing collisions...

the2bears20:09:48

@madstap what is the fully-qualified class name of the fn in the aot'ed jar?

madstap21:09:36

@the2bears The clojure names of the fns are foo.common.core/replace-_ (and replace_-). The class in the jar is /foo/common/core$replace__.class

the2bears21:09:53

Yeah, interesting... like you stated, the munging is very ambiguous in this case 🙂

andy.fingerhut22:09:02

I could be wrong, but it isn't clear to me whether there is a straightforward way for the compiler to detect that name-munging produces collisions. I say that because there is no warning, and likely never will be, if you defn the same function name multiple times (same even before the name is munged). Detecting that was one of the motivating use cases for me hacking on Eastwood for a while.

andy.fingerhut22:09:09

Clojure has no warning for that because it is such a common use case in REPL workflows to redefine functions.

andy.fingerhut22:09:48

But perhaps in the specific case of 'during aot compilation' it might be straightforward to detect when writing a .class file that already exists.

hiredman22:09:47

which would also remind people to clean out their stale class files

andy.fingerhut22:09:14

@madstap What version of Clojure are you using? This behavior might be better with Clojure 1.9 than in Clojure 1.8.

madstap22:09:03

I'm on 1.9

andy.fingerhut23:09:16

Never mind on my last comment -- I think I confused myself with some test expressions I was evaluating.

andy.fingerhut23:09:48

No promises on whether Eastwood ever will have such a check, but I've created a Github issue for it in case someone decides to run with the idea and implement it: https://github.com/jonase/eastwood/issues/281

👍 1