Elm Exactly
Results / elm-error-catalogue /

ErrorMessagesIssue228ComparableListHintTest

Tags:elm19-bugerror-message

elm-0.19.1 failelm-0.19.2 failelm-0.19.3 faillamdera-1.5.0 fail

Issue: elm/error-message-catalog#228

A Set of lists of a custom type is rejected (the custom type is not comparable), but the
hint blames the List.

<https://github.com/elm/error-message-catalog/issues/228>

Elm 0.19.1 rejects `Set.fromList [ [ Apple ] ]` with a TYPE MISMATCH whose hint says "I do not
know how to compare `List` values. I can only compare ... lists of comparable values". Lists
are comparable; it is `Fruit` that is not, so the hint is false.

Results

elm-0.19.1

fail
Unexpected pattern (CHECK-NOT): I do not know how to compare `List` values
--- compiler output ---
Compiling ...-- TYPE MISMATCH ----------- src/ErrorMessagesIssue228ComparableListHintTest.elm

The 1st argument to `fromList` is not what I expect:

29|     Set.fromList [ [ Apple ], [ Banana ] ]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
This argument is a list of type:

    List (List Fruit)

But `fromList` needs the 1st argument to be:

    List comparable

Hint: I do not know how to compare `List` values. I can only compare ints,
floats, chars, strings, lists of comparable values, and tuples of comparable
values.

Check out <https://elm-lang.org/0.19.1/comparing-custom-types> for ideas on how
to proceed.

Detected problems in 1 module.

elm-0.19.2

fail
Unexpected pattern (CHECK-NOT): I do not know how to compare `List` values
--- compiler output ---
Compiling ...-- TYPE MISMATCH ----------- src/ErrorMessagesIssue228ComparableListHintTest.elm

The 1st argument to `fromList` is not what I expect:

29|     Set.fromList [ [ Apple ], [ Banana ] ]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
This argument is a list of type:

    List (List Fruit)

But `fromList` needs the 1st argument to be:

    List comparable

Hint: I do not know how to compare `List` values. I can only compare ints,
floats, chars, strings, lists of comparable values, and tuples of comparable
values.

Check out <https://elm-lang.org/0.19.2/comparing-custom-types> for ideas on how
to proceed.

Detected problems in 1 module.

elm-0.19.3

fail
Unexpected pattern (CHECK-NOT): I do not know how to compare `List` values
--- compiler output ---
Compiling ...-- TYPE MISMATCH ----------- src/ErrorMessagesIssue228ComparableListHintTest.elm

The 1st argument to `fromList` is not what I expect:

29|     Set.fromList [ [ Apple ], [ Banana ] ]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
This argument is a list of type:

    List (List Fruit)

But `fromList` needs the 1st argument to be:

    List comparable

Hint: I do not know how to compare `List` values. I can only compare ints,
floats, chars, strings, lists of comparable values, and tuples of comparable
values.

Check out <https://elm-lang.org/0.19.3/comparing-custom-types> for ideas on how
to proceed.

Detected problems in 1 module.

lamdera-1.5.0

fail
Unexpected pattern (CHECK-NOT): I do not know how to compare `List` values
--- compiler output ---
Detected problems in 1 module.
-- TYPE MISMATCH ----------- src/ErrorMessagesIssue228ComparableListHintTest.elm

The 1st argument to `fromList` is not what I expect:

29|     Set.fromList [ [ Apple ], [ Banana ] ]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
This argument is a list of type:

    List (List Fruit)

But `fromList` needs the 1st argument to be:

    List comparable

Hint: I do not know how to compare `List` values. I can only compare ints,
floats, chars, strings, lists of comparable values, and tuples of comparable
values.

Check out <https://elm-lang.org/0.19.3/comparing-custom-types> for ideas on how
to proceed.

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-error-catalogue/ErrorMessagesIssue228ComparableListHintTest] in its title.

Source

The -- CHECK: lines give the expected output.

module ErrorMessagesIssue228ComparableListHintTest exposing (main)
{-| A Set of lists of a custom type is rejected (the custom type is not comparable), but the
hint blames the List.
<https://github.com/elm/error-message-catalog/issues/228>
Elm 0.19.1 rejects `Set.fromList [ [ Apple ] ]` with a TYPE MISMATCH whose hint says "I do not
know how to compare `List` values. I can only compare ... lists of comparable values". Lists
are comparable; it is `Fruit` that is not, so the hint is false.
-}
-- TAGS: elm19-bug, error-message
-- COMPILE-ERROR: Set of lists of a custom type
-- CHECK: -- TYPE MISMATCH -
-- CHECK-NOT: I do not know how to compare `List` values
import Html exposing (text)
import Set
type Fruit
= Apple
| Banana
s =
Set.fromList [ [ Apple ], [ Banana ] ]
main =
text (String.fromInt (Set.size s))