elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
174 stars 17 forks source link

Compiling an empty model gives unhelpful error message #318

Open dasch opened 5 years ago

dasch commented 5 years ago

Elm version: 0.19.1.

Given this source:

module Main exposing (..)

When compiling with elm make src/Hello.elm, I get the following error message.

Detected problems in 1 module.
-- EMPTY MODULE --------------------------------------------- src/Hello.elm

I am trying to parse a declaration, but I am getting stuck here:

2|
   ^
When a line has no spaces at the beginning, I expect it to be a declaration like
one of these:

    greet : String -> String
    greet name =
      "Hello " ++ name ++ "!"

    type User = Anonymous | LoggedIn String

Try to make your declaration look like one of those? Or if this is not supposed
to be a declaration, try adding some spaces before it?

Coming from many other languages, you'd typically consider compiling an empty class or module after saving it, as a small step to check that things are working. Or even when learning Elm, wanting to add one line at a time.

How about either 1) not considering this an error at all, or 2), use a more helpful error message, e.g.

Detected problems in 1 module.
-- WEIRD DECLARATION --------------------------------------------- src/Hello.elm

Modules in Elm need at least one declaration, for example a function or type definition.

Try adding this to your module:

    greet : String -> String
    greet name =
      "Hello " ++ name ++ "!"

If you need help writing your first module, check out this tutorial: <https://guide.elm-lang.org/webapps/modules.html>.
kumkee commented 1 year ago

Got the same very unhelpful error message when trying out elm-ui.