typelead / eta

The Eta Programming Language, a dialect of Haskell on the JVM
https://eta-lang.org
BSD 3-Clause "New" or "Revised" License
2.6k stars 142 forks source link

Error: Multiple declarations with names differing only in case. #965

Open jneira opened 5 years ago

jneira commented 5 years ago

Description

Context

rahulmutt commented 5 years ago

Yes, this has been mildly annoying. That error was added to avoid weird ClassNotFoundErrors at runtime. The true solution is to: 1) Just before writing to interface files, attach a new data item to the Var type that stores the name which the codegenerator should assign to that particular binding. This addition is generally useful later when we want to give the user the ability to control the generated package/class for data types (say you wanted to rename the list type). 2) Do an iteration where you store all the case-insensitive names into a map and if there's a clash, add a $[n] as a suffix where [n] is an incrementing index.

Say the binders are:

hello, heLlo, Hello

We could attach:

hello, heLlo$1, Hello$2

So that absolutely no clash can happen. 3) Make sure the codegen peeks into the newly added field before deciding the class name for a newly generated class. Moreover, when generating calls to binders in other modules, ensure that the field is used and not the standard encoding.