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

Error message when miscapitalizing a boolean value could be clearer #279

Open bowbahdoe opened 5 years ago

bowbahdoe commented 5 years ago
Naming Error
Line 36, Column 31
I cannot find a `false` variable:

36|   ( Model "cat" "waiting.gif" false
                                  ^^^^^
These names seem close though:

    value
    abs
    alt
    class

Hint: Read <https://elm-lang.org/0.19.0/imports> to see how `import`
declarations work in Elm.

This is the error message that you get as of 0.19.0 when you write false instead of False. This seems like it would be a common enough stumbling block to be more directly explained to the user. Something like "the boolean false is written with a capital "F" in Elm`.

Herteby commented 5 years ago

I think the capitalization check could even be extended to all typos. For example if you have:

type alias User = { firstName : String, lastName : String }

user = User "Simon" "Herteby"

view model = div [] [ text User.firstName ]

It gives you the error:

I cannot find a `User.firstName` variable:

37|         [ text User.firstName, button [ onClick Increment ] [ text "+1" ]
                   ^^^^^^^^^^^^^^
I cannot find a `User` import. These names seem close though:

    Html.iframe
    Tuple.first
    Char.fromCode
    isInfinite

Hint: Read <https://elm-lang.org/0.19.0/imports> to see how `import`
declarations work in Elm.

It ought to be able to figure out that it was probably a typo, and user.firstName would be correct, since that would match the expected signature..

ie. make the typo suggestions more general I guess, instead of only having it for record fields.

actually maybe this should be it's own issue, if it doesn't already exist :thinking: