What can we do to make error reporting better. #12101
Replies: 3 comments 3 replies
-
Tangent to the main thread: Rust has something like an error index. When the compiler outputs an error message it outputs also a link (or |
Beta Was this translation helpful? Give feedback.
-
I'd briefly raise the following couple of points for consideration:
I like the idea that errors could be numbered, maybe with a prefix that's short enough to type quickly, while being unique enough that Google will produce relevant results without the user needing to add additional search terms (e.g. "scala") to find results explaining the error. |
Beta Was this translation helpful? Give feedback.
-
We decided to instead move reporting and discussion of error messages to individual issues - campaign coming soon, but we have begun with the new issue template for reporting problematic errors. The other part of this discussion covered the creation of a rust-style error index, which is also discussed here |
Beta Was this translation helpful? Give feedback.
-
Good error reporting is hard. Compiler ideally should not only tell the user that they have made a mistake but also why given code is not expressing what user intended it to do. Of course it not possible to always guess the intentions of the users and in many cases where it is possible it would require lots of work both from the compiler team and compiler itself during the compilation. Making every error message as expressive and self-explanatory as possible is not worth the effort, especially when there are multiple more pressing issues.
Nevertheless I think it may be beneficial to create discussion thread for sharing cases where error messages are misleading, especially for newcomers. I hope that for some of them we can discuss small improvements that can be implemented without much effort sometime later, and generally improve the situation.
First class of errors that is not friendly to the newcomers are "raw" errors from the parser. They are usually only stating that some token were unexpected and that token is often somewhere else than the real source of the problem.
Example: compiler is reporting that
:
was expected in the place of)
even though the true error was illegalinline
modifier.:
instead ofwith
in givens orextends
in classes,:
instead of=
in multiline defs,->
instead of=>
,T =>> M[T]
instead of[T] =>> M[T]
etc.The other class of errors is mixing types and companion objects instances. The thing that prompted me to start this thread was error encountered by one of my colleagues earlier today. He wanted to use union types in the pattern matching.
case _: A | B | C
he wrote, was interpreted ascase (_: A) | B | C
giving him strange error message suggesting that something is wrong with type inference..type
at the end.Beta Was this translation helpful? Give feedback.
All reactions