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

Unclear/misleading error when missing type parameter in type definitions #236

Closed gyzerok closed 3 years ago

gyzerok commented 7 years ago

SSCCE

https://ellie-app.com/4bwZVb3bnPGa1/2

type Test a b c
    = A a
    | B b
    | C c

testAsString : Test String Int -> String
testAsString test =
    case test of
        A str ->
            str

        B int ->
            toString int

        C str ->
            str

Actual error

Tag **Main.A** is causing problems in this pattern match.
The pattern matches things of type:

Test a b c

But the values it will actually be trying to match are:

Test String Int

Expected error

The error is actually not in pattern match but in type definition. One forgot to specify extra type parameter.

I would expect to see something along the lines:

Type Test String Int is causing problems in this type definition.

42| testAsString : Test String Int -> String
                   ^^^^^^^^^^^^^^^
Type Test a b c was given 2 parameters:

testAsString : Test String Int -> String

But it expects 3:

testAsString : Test String Int c? -> String
gyzerok commented 3 years ago

I prefer to keep my lists of issues and PRs clean of non-actionable items, so closing this.

Feel free to open on your own by copypasting the content.