Quick Summary: When a module imports another module with the wrong casing (import ABC when the module is named Abc), the compiler reports a MODULE NAME MISMATCH which doesn't indicate the real source of the problem.
-- src/Main.elm
module Main exposing (main)
import Html exposing (text)
-- Notice the casing for this module is wrong
import Mymodule
main = text "Hello world"
-- src/MyModule.elm
module MyModule exposing (a)
a = 1
Elm: 0.19.1
Browser: NA
Operating System: MacOS
Additional Details
When you run the Elm compiler with the example above, you get this error message:
-- MODULE NAME MISMATCH --------------------------------------- src/Mymodule.elm
It looks like this module name is out of sync:
1| module MyModule exposing (a)
^^^^^^^^
I need it to match the file path, so I was expecting to see `Mymodule` here.
Make the following change, and you should be all set!
MyModule -> Mymodule
Note: I require that module names correspond to file paths. This makes it much
easier to explore unfamiliar codebases! So if you want to keep the current
module name, try renaming the file instead.
This error message is actively unhelpful, because it makes you look at the wrong thing. Instead, it should tell you either that this import does not exist, or tell you that the casing is wrong on the import.
I don't know if this replicates on case-sensitive machines like Linux, it might be due to Mac's case-insensitivity on file paths.
Quick Summary: When a module imports another module with the wrong casing (
import ABC
when the module is namedAbc
), the compiler reports aMODULE NAME MISMATCH
which doesn't indicate the real source of the problem.SSCCE
In case it's helpful, I've made this SSCCE into its own repo: https://github.com/jfmengels/elm-compiler-case-mismatch-sscce
Additional Details
When you run the Elm compiler with the example above, you get this error message:
This error message is actively unhelpful, because it makes you look at the wrong thing. Instead, it should tell you either that this import does not exist, or tell you that the casing is wrong on the import.
I don't know if this replicates on case-sensitive machines like Linux, it might be due to Mac's case-insensitivity on file paths.