In my experience as a developer, a single syntax error made in a long program can result in a long cascading list of error messages, only the first of which is directly relevant to the solution. For example, consider the following malformed C# program:
namespace Spaaaaaace
{
public static class RequiredTestProtocol
{
public static void Test()
{
Console.WriteLine("As part of a required test protocol, we must run this program successfully.");
// MISSING CLOSE BRACE
public static void Main(string[] args)
{
Test();
}
}
}
When I attempt to compile this program, I not only see the error about the missing close brace, but an additional message about how declaring public
members within a function is not allowed, which is something I never intended to do. This additional message is solely a result of my initial error and has nothing to do with any error I made in my Main
function.
On the other hand, it is entirely possible for a programmer to make multiple, independent compile-time errors within one program under circumstances in which the programmer might want to know about each instance. An example could be declaring multiple for
loops, each of which is malformed.
Are there ways to differentiate each of these cases at compile time? That is, if a compiler has decided that there are multiple compile errors to report, is there a way for it to determine whether these are all independent errors or whether some or all of the later errors would be fixed by fixing an earlier error, and then reporting only the "real" errors?