Closed nonpop closed 5 years ago
I made a fix in https://github.com/elm/compiler/commit/545b1784695500e822c2d044b6b5ed2ab6689552, so my development build is now producing:
-- TYPE MISMATCH ------------------------------------------------------ temp.elm
Something is off with the body of the `sscce` definition:
7| Set.fromList [ ( 0, {} ) ]
^^^^^^^^^^^^^^^^^^^^^^^^^^
This `fromList` call produces:
Set.Set comparable
But the type annotation on `sscce` says it should be:
Dict.Dict Int {}
-- TYPE MISMATCH ------------------------------------------------------ temp.elm
The 1st argument to `fromList` is not what I expect:
7| Set.fromList [ ( 0, {} ) ]
^^^^^^^^^^^^^
This argument is a list of type:
List ( number, {} )
But `fromList` needs the 1st argument to be:
List comparable
Hint: Only ints, floats, chars, strings, lists, and tuples are comparable.
I am going to try to make the hint more specific. I'm hoping it can specifically mention that records are not comparable, but I'm not sure if it'll be doable!
I tried making the hint really extra specific, but I ended up needing to rewrite some code that would be a bit too risky to change this close to a release. I ended up with some logic that should improve the hints on comparable clashes, but not in cases where a comparable
constraint is having trouble with a type within a list or tuple.
Anyway, thank you for reporting the error here!
Trying to compile this
causes the following error message:
Replacing the
{}
type withString
and giving a string argument gives the helpful error:EDIT: I just noticed that in the first case Elm actually produces two error messages, including the helpful one.