compiler
compiler copied to clipboard
Color use in error messages
If I have a type error when defining a record the compiler will give an error message with the most valuable information using color alone.
E.g.
type alias Model =
{ count : Int
, a: String
, b: List String
, c: Float
}
initialModel : Model
initialModel =
{ count = 0
, a = 1
, b = []
, c = 0
}
Error:
Something is off with the body of the `initialModel` definition:
18|> { count = 0
19|> , a = 1
20|> , b = []
21|> , c = 0
22|> }
The body is a record of type:
{ a : number, b : List String, c : Float, count : Int }
But the type annotation on `initialModel` says it should be:
Model
In a terminal with colors, number will be highlighted. But apart from that you cannot tell where the error is.
This has some issues:
- Relying on color alone is not a great accessibility practice
- In several environments the colors are gone. e.g. when showing an error in the Browser dev console or when using something like Docker for development.
It would be great if the error is spelled out in text.
I didn't know this error message had helpful hints on what you did wrong, because I've been seeing it without colors for years! It's a pretty unhelpful error message without them.
This problem is made worse by the choice to not fix https://github.com/elm/compiler/issues/1803, because sometimes you cannot wrap Elm in a PTY.
Regardless of the difficulty in forcing colored output, reiterating what OP said, color is bad for accessibility. Achromatopsia is pretty rare (1/30k people), but people on screenreaders won't have colors read out to them either.
would love a specific error here. I too have never noticed the color thing and have had to figure out the problem myself rather than from the error.