elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.53k stars 663 forks source link

Compiler crash on external module name duplicate #2224

Open csaltos opened 3 years ago

csaltos commented 3 years ago

First of all, thank you Evan for Elm, it's great and it brings me new joy to programming in my life and with my company and colleges !!

Quick Summary: if you import a dependency with the same name of one of your modules, the compiler crashes

SSCCE

src/Countries.elm:

module Countries exposing (dummy)

dummy : Int
dummy = 1

elm.json:

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/browser": "1.0.2",
            "elm/core": "1.0.5",
            "elm/html": "1.0.0",
            "supermario/elm-countries": "1.1.1"
        },
        "indirect": {
            "elm/json": "1.1.3",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm/virtual-dom": "1.0.2"
        }
    },
    "test-dependencies": {
        "direct": {},
        "indirect": {}
    }
}

Additional Details

Compiler error:

-- ERROR -----------------------------------------------------------------------

I ran into something that bypassed the normal error reporting process! I
extracted whatever information I could from the internal error:

>   Error from `Countries` should have been reported already.
>   CallStack (from HasCallStack):
>     error, called at builder/src/Build.hs:1233:29 in main:Build

These errors are usually pretty confusing, so start by asking around on one of
forums listed at https://elm-lang.org/community to see if anyone can get you
unstuck quickly.

-- REQUEST ---------------------------------------------------------------------

If you are feeling up to it, please try to get your code down to the smallest
version that still triggers this message. Ideally in a single Main.elm and
elm.json file.

From there open a NEW issue at https://github.com/elm/compiler/issues with your
reduced example pasted in directly. (Not a link to a repo or gist!) Do not worry
about if someone else saw something similar. More examples is better!

This kind of error is usually tied up in larger architectural choices that are
hard to change, so even when we have a couple good examples, it can take some
time to resolve in a solid way.elm: Error from `Countries` should have been reported already.
CallStack (from HasCallStack):
  error, called at builder/src/Build.hs:1233:29 in main:Build

NOTE: the solution is kind of easy, just rename the clashing module to something else but finding that is the cause of the error was long and a pain ... I hope a solution can be discovered since this happens with any external module name clashing.

Once again, thank you very much !!

github-actions[bot] commented 3 years ago

Thanks for reporting this! To set expectations:

Finally, please be patient with the core team. They are trying their best with limited resources.