Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Add hint or warning when importing a package that has the same name as the current file #104

Open
pjambet opened this issue Jun 13, 2016 · 2 comments
Labels

Comments

@pjambet
Copy link

pjambet commented Jun 13, 2016

Hi,

I was working through the online tutorial, and when playing with the random example, I stumbled upon a weird compiler issue when trying to run the file through elm-reactor

I found multiple modules named 'Random'.

Module 'Main' is trying to import it.

Modules with that name were found in the following locations:

    directory ././Random.elm
    package elm-lang/core

I realized the file I was trying to run was named random.elm, which seems to cause a conflict when if the file contains the line import Random.

It took me a few minutes to understand what was happening (mostly because I'm an absolute beginner and don't know much about elm), but based on the excellent compiler error that elm uses, I thought that this could be something that could be improved.

It seems like if one of the import statements matches the current file, a warning (or an error) could be issued.
We could also maybe make the line directory ././Random.elm a little bit more explicit to illustrate that it references the current file.

Those are just my current thoughts, there could obviously be better options.

I would be happy to work on those improvements (if they are deemed valid), but I'm not exactly sure how the compiler really works. All I found so far is this file, that seems to be involved in the process.
It could be a good reason for me to start learning some haskell!

PS: Really loving elm so far, thank you so much for everything!


Using elm 0.17.0 on mac OS

@process-bot
Copy link

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@matthamil
Copy link

matthamil commented Nov 7, 2016

I got this exact problem while working on https://guide.elm-lang.org/architecture/effects/random.html. A note should be added to this page in particular to signal to new Elm developers this potential name collision issue.

EDIT: Opened a PR to address this here evancz/guide.elm-lang.org#67

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

No branches or pull requests

4 participants