elm / error-message-catalog

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

Confusing error message with type alias and incorrect list item type #288

Open nonpop opened 5 years ago

nonpop commented 5 years ago

Trying to compile this module:

module SSCCE exposing (sscce)

type alias ListOfInts =
    List Int

sscce : ListOfInts -> ListOfInts
sscce list =
    "oops" :: list

gives the following error messages:

-- TYPE MISMATCH ------------------------------------------------- src/SSCCE.elm

Something is off with the body of the `sscce` definition:

10|     "oops" :: list
        ^^^^^^^^^^^^^^
The body is:

    List String

But the type annotation on `sscce` says it should be:

    ListOfInts

-- TYPE MISMATCH ------------------------------------------------- src/SSCCE.elm

The (::) operator can only add elements onto lists.

10|     "oops" :: list
                  ^^^^
This `list` value is a:

    ListOfInts

But (::) needs a List on the right.