Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jneira opened this issue May 22, 2019 · 1 comment
Open

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

jneira opened this issue May 22, 2019 · 1 comment

Comments

@jneira
Copy link
Collaborator

jneira commented May 22, 2019

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

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants