Compiler error messages: show just the first, or all of them?

Yes, I’ve mostly programmed in Python first and then moved to programming in Kotlin.

1 Like

OK.

If for example you have just forgotten to declare several variables, you will have several error messages and they will be correct. You can then fix them all before recompiling.

There are several strategies how the compiler can report multiple errors that are high quality, such as:

  • Only reporting one error per node and poison all dependent nodes
  • Only fixing the error if we are almost sure the fix is correct, otherwise the fix generates many other spurious errors; But this is really tricky.

For example I think you can safely report any local misdeclared variables in separate subroutines in a module; but if the variable is just not declared, maybe it could be a module variable, or there is a missing use, that would fix all of the errors in all subroutines.

I think this is an interesting research problem on its own how to do this.

2 Likes

A compiler should have the option to report only the first N errors in a source file, and many do. An LLM such as ChatGPT, given a source file and the compiler error and warning messages, often produces a good diagnosis of the problem and how it can be fixed. I often take advantage of this in Python. Given the power of LLMs in this area, I wonder if compiler developers should be spending much time on manually improving error messages.

2 Likes

My usual approach is to compile the code and the place the error messages in one window, and then edit the source file in another window. I scan through the error messages and keep fixing them until I start to see ones that are cascading errors that I just fixed, and then I recompile and start over.

2 Likes