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

Pattern matching on literals only #246

Open pdavidow opened 6 years ago

pdavidow commented 6 years ago
string_Random_TreeRandomInsertStyle = "Insert Random L/R"
string_Right_TreeRandomInsertStyle = "Insert Right"
string_Left_TreeRandomInsertStyle = "Insert Left"

treeRandomInsertStyleDecoder : String -> Decoder TreeRandomInsertStyle
treeRandomInsertStyleDecoder value =
    case value of
        string_Random_TreeRandomInsertStyle -> Decode.succeed TreeRandomInsertStyle.Random
        string_Right_TreeRandomInsertStyle -> Decode.succeed TreeRandomInsertStyle.Right
        string_Left_TreeRandomInsertStyle -> Decode.succeed TreeRandomInsertStyle.Left
        _ -> Decode.fail "Invalid TreeRandomInsertStyle

gives

The following pattern is redundant. Remove it.

90|         string_Right_TreeRandomInsertStyle -> Decode.succeed TreeRandomInsertStyle.Right
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Any value with this shape will be handled by a previous pattern.

but should rather state that Elm only matches against literals not values