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

Redundant pattern for Bool #210

Open shishkin opened 7 years ago

shishkin commented 7 years ago

I define a message type like this:

type Msg
    = SignedIn Bool

And then pattern match on it in update like this:

    case msg of
        SignedIn true ->
            ( 1, Cmd.none )

        SignedIn false ->
            ( -1, Cmd.none )

And get the following compiler error:

-- REDUNDANT PATTERN ---------------------------------------------- src/Main.elm

The following pattern is redundant. Remove it.

28|         SignedIn false ->
            ^^^^^^^^^^^^^^
Any value with this shape will be handled by a previous pattern.

As a newcomer to Elm I've made a mistake of writing Bool values in small case so that they're interpreted as variables. It would help newcomers to suggest a casing mistake instead when matching Bool values.

d-arkhipenko commented 4 years ago

Hi, it seems like a good place to add another issue related to Bool type. Could we add on top of suggesting words the variant with 'True'?

Screenshot 2020-06-11 at 12 38 46 Screenshot 2020-06-11 at 12 38 00