compiler
compiler copied to clipboard
Error message from generic signature with records is inconsistent with other errors from generic signatures
Quick Summary: Error message from generic signature with records is inconsistent with other errors from generic signatures. The error message should be similar to the one posted under Additional details
SSCCE
In the REPL:
> r1 : { x : a } -> String
| r1 r = String.concat [ r.x, "Hello" ]
|
-- TYPE MISMATCH ---------------------------------------------------------- REPL
The 2nd element of this list does not match all the previous elements:
3| r1 r = String.concat [ r.x, "Hello" ]
^^^^^^^
The 2nd element is a string of type:
String
But all the previous elements in the list are:
a
- Elm: 0.19.1
- Browser: REPL
- Operating System: macOS Big Sur
Additional Details
A similar example without records, the error message is more useful and accurate:
> f: a -> String
| f r = String.append "Hello"
|
-- TYPE MISMATCH ---------------------------------------------------------- REPL
Something is off with the body of the `f` definition:
3| f = String.append "hello"
^^^^^^^^^^^^^^^^^^^^^
This `append` call produces:
String -> String
But the type annotation on `f` says it should be:
a -> String
Hint: Your type annotation uses type variable `a` which means ANY type of value
can flow through, but your code is saying it specifically wants a `String`
value. Maybe change your type annotation to be more specific? Maybe change the
code to be more general?
Thanks for reporting this! To set expectations:
- Issues are reviewed in batches, so it can take some time to get a response.
- Ask questions in a community forum. You will get an answer quicker that way!
- If you experience something similar, open a new issue. We like duplicates.
Finally, please be patient with the core team. They are trying their best with limited resources.