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

Capitalization mistakes #231

Open rtfeldman opened 7 years ago

rtfeldman commented 7 years ago

I saw this in #beginners on Elm Slack:

what am i doing wrong here - says that I have a naming error Cannot find pattern OK

They used OK instead of Ok. At a glance, I can see how someone might look at their code and look at the suggestion of Did you mean "Ok"? and not spot the distinction.

Hints could detect when one of the suggestions matches what you typed exactly, except for capitalization (e.g. with if String.toLower actual == String.toLower suggestion) and call this out. Something like:

Did you mean:

Ok (Note the different capitalization from OK) Okra Octopus

MartinSStewart commented 4 years ago

Related to this. Capitalization mistakes in records produce unhelpful error messages. Someone using elm-ui got stuck with this error and it took me several minutes before I noticed onchange should be onChange

This argument is a record of type:    
    { checked : Bool
    , icon : Bool -> Element msg1
    , label : Label msg
    , onchange : Bool -> Msg
    }
But `checkbox` needs the 2nd argument to be:    
    { checked : Bool
    , icon : Bool -> Element msg
    , label : Label msg
    , onChange : Bool -> msg
    }