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

Dict.insert given type mismatch error when it should be given Arg count error. #276

Open sarasfox opened 5 years ago

sarasfox commented 5 years ago

These work.

{ model | gameData = Dict.insert model.game { game | players = List.Extra.unique (List.append game.players [ model.player ]) } model.gameData }
{ model | gameData = Dict.insert model.game { players = [ model.player ] } model.gameData }

But these give worry error

{ model | gameData = Dict.insert model.game { game | players = List.Extra.unique (List.append game.players [ model.player ]) } }
--ERROR

I cannot update the `gameData` field like this:

85|             { model | gameData = Dict.insert model.game { game | players = List.Extra.unique (List.append game.players [ model.player ]) } }
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This `insert` call produces:

    Dict String { players : List String }
    -> Dict String { players : List String }

But it should be:

    Dict String Game

Note: The record update syntax does not allow you to change the type of fields.
You can achieve that with record constructors or the record literal syntax.
{ model | gameData = Dict.insert model.game { players = [ model.player ] } }
--ERROR

I cannot update the `gameData` field like this:

88|             { model | gameData = Dict.insert model.game { players = [ model.player ] } }
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This `insert` call produces:

    Dict String { players : List String }
    -> Dict String { players : List String }

But it should be:

    Dict String Game

Note: The record update syntax does not allow you to change the type of fields.
You can achieve that with record constructors or the record literal syntax.

OH

type alias Game =
    { players : List String }
Benjoyo commented 5 years ago

I found this to be confusing as well