Error: Multiple declarations with names differing only in case.
jneira opened this issue · 1 comments
jneira commented
Description
- ghc accepts definitions that only differ in case but eta doesn't
- With this file
module Main where
ff = 0
fF = 1
main = print ff >> print fF
eta throws:
Example.hs:5:1: error:
Multiple declarations with names differing only in case.
Declared at: Example.hs:3:1
Example.hs:5:1
|
5 | fF = 1
| ^^
Expected Behavior
eta should behave like ghc
Actual Behavior
it throws the error included above
Possible Fix
Context
- Paching duckling library and some another one i had to rename definitions to avoid the error.
Your Environment
- Did you install an older version of Eta/Etlas before? YEs
- Current Eta & Etlas version: 0.8.6b5 and 1.6.0.0 built from master
- Operating System and version: windows 10
- Link to your project:
rahulmutt commented
Yes, this has been mildly annoying. That error was added to avoid weird ClassNotFoundErrors at runtime. The true solution is to:
- 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). - 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.