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

Generic error message when type alias is missing 'alias' #324

Open ianmackenzie opened 4 years ago

ianmackenzie commented 4 years ago

For example, something like

type MaybeInt =
   Maybe.Maybe Int

leads to a pretty generic error message

-- UNEXPECTED SYMBOL ------------------------------------------ ErrorMessage.elm

I ran into an unexpected symbol:

5|     = Maybe.Maybe Int
              ^
I was not expecting to see a . here. Try deleting it? Maybe I can give a better
hint from there?

This seems like it might be a bit of a regression in 0.19.1, since when I tried on Ellie I instead got

Line 22, Column 10
Something went wrong while parsing a union type.

21| type MaybeInt =
22|     Maybe.Maybe Int
             ^
I was expecting:

  - a type, like Int or (List String)
  - a vertical bar (|) followed by more union type constructors
  - more of that union type. Maybe you forgot some code? Or you need more
    indentation?

which is significantly better (at least it highlights that Elm is parsing the declaration as a custom type instead of a type alias).