Fork me on GitHub
#clojure
<
2023-03-12
>
borkdude13:03:04

Is this a clojure / tools / build problem or should it be a linter problem? Happy to add support, but would be good to know before going in. https://github.com/clj-kondo/clj-kondo/issues/2006 (tl;dr: capitalized variations of the same name for different vars leads to problems on case-insensitive file systems)

Alex Miller (Clojure team)15:03:49

It’s a known issue, but not one we plan to address in Clojure afaik. I would say don’t use two source files that are the same insensitive to case

Alex Miller (Clojure team)15:03:26

Seems like some lib ran into this years ago, but maybe that was specifically with vars (which may become classes on disk at some point), maybe it was camel-snake-kebab?

borkdude15:03:42

the clj-kondo 2006 issue is about vars which get compiled to classes as well

borkdude16:03:29

I guess it's better to avoid it then, would it be good to make this a default linter (as opposed to opt-in)?

emccue16:03:25

Java also has this problem btw.

borkdude16:03:23

right, if anything, this should be solved at the level of the JVM, rather than clojure

borkdude21:03:34

I looked a bit deeper into this and when I compile a namespace like this:

(ns scratch)

(defn Foo1 [])

(defn FOO1 [] (Foo1))
I only see one scratch$Foo1.class file and not a second scratch$FOO1.class - is this expected? Maybe I'm doing something wrong.

Alex Miller (Clojure team)21:03:28

What kind of filesystem?

borkdude21:03:42

let me check the filesystem

Alex Miller (Clojure team)21:03:49

Mac is insensitive but preserving by default

Alex Miller (Clojure team)21:03:18

So in checking the class on the second one it will look like it’s already there

emccue21:03:20

(Mac does Unicode normalize though, which can cause its own issues)

Alex Miller (Clojure team)21:03:55

So, this is the expected (confusing) behavior and the reason you should not do this :)

borkdude21:03:37

cool, I thought it was only a problem on Windows, but it seems there's even more reasons to avoid it :)

borkdude09:03:20

@UR1CCJ8MS implemented this linter and I'm finding various cases like this. E.g in transit-clj:

(deftype Reader [r])

(defn reader [])
also for writer. In clojure core even for Eduction and eduction. Has this ever caused problems for any people? If not, why not? It seems we need to tune down the linter in that case?

borkdude15:03:53

Ah the non-issue between deftype Reader and defn reader is that reader is emitted as classes/scratch/reader.class but Reader is emitted as classes/scratch/scratch/Reader.class , so no conflict

Emlyn Corrin17:03:02

OK, so it looks like we should consider definterface, defprotocol, defrecordand deftype as one set of names, and defn, defn-, definline and defmacro as another set, and look for conflicts within each set but not between them?

borkdude17:03:56

yes, I guess we could just collect a bucket of names and prepend the namespace name to those definterface etc with a dot, similar to how it's done on disk, or so

borkdude17:03:09

or maintain two different buckets for each kind