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

Got type X instead of type Y having single variant X #339

Open malaire opened 4 years ago

malaire commented 4 years ago

I recently got this kind of error

Something is off with the body of the `someFunc` definition:
...
The body is a list of type:

    List (Maybe { someField : Bool })

But the type annotation on `someFunc` says it should be:

    List SomeRecord

where SomeRecord is defined as

type SomeRecord
    = Maybe { someField: Bool }

The error here is missing alias from type SomeRecord, which makes type to have a single variant Maybe, instead of being alias to type Maybe what is used in the function.

This error can be tricky to notice, so it would be nice if compiler could detect that type Maybe and variant Maybe have same name, and report this.