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

capitalisation typo #98

Closed stiller closed 8 years ago

stiller commented 8 years ago

In https://github.com/evancz/elm-architecture-tutorial/blob/master/examples/3/CounterList.elm#L39 I had accidentally typed model.Counters instead of model.counters, which resulted in this error:

The argument to function `start` is causing a mismatch.

5│   start
6│>    { model = init
7│>    , update = update
8│>    , view = view
9│>    }

Function `start` is expecting the argument to be:

    { ..., update : CounterList.Action -> { ... } -> { ... } }

But it is:

    { ...
    , update :
          CounterList.Action
          -> { a | ..., Counters : ... }
          -> { a | ..., Counters : ... }
    }

Which does hint that the error lies in the second field of the record, but perhaps it could be a bit more focussed. I wonder if model.Counters ++ [ newCounter ] is even valid syntax.

jvoigtlaender commented 8 years ago

It's not valid syntax, and even more worrying is that the compiler error message prints a type that would also never be valid (even if the ... were filled somehow). So I think this is not just a bad error message, it is a true compiler bug. The compiler should not say that { a | ..., Counters : ... } is an Elm type.

I suggest you open an issue at https://github.com/elm-lang/elm-compiler/issues.

stiller commented 8 years ago

After adding type annotation, the error is a little more succinct, but still not correct, I think:

34│ update : Action -> Model -> Model
             ^^^^^^^^^^^^^^^^^^^^^^^^
The type annotation is saying:

    Action -> { ... } -> { ... }

But I am inferring that the definition has this type:

    Action -> { a | ..., Counters : ... } -> { a | ..., Counters : ... }
rtfeldman commented 8 years ago

This has a compiler issue in https://github.com/elm-lang/elm-compiler/issues/1374 now. Thanks for reporting!