[Issue 2464] New: Correct error message causes incorrect error messages

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 19 19:45:24 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2464

           Summary: Correct error message causes incorrect error messages
           Product: D
           Version: 1.033
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: jminer2613 at students.pcci.edu


This bug I have seen many times. The following block of code has a clear error:
it refers to the variable k that does not exist. The compiler correctly reports
that error. However, when it reports the error in line 8, it also reports 5
more errors, even though there are no other errors. The compiler will report no
errors if the k is changed to j on line 8.

This not only happens with an undefined identifier error; many other errors
cause the same problem. (trying to concatenate two numbers, leaving out the
comma in a foreach, using the wrong type in a with statement, using = in an if
statement, etc.)

If you use a few void-inferred delegates and misspell one variable name, the
compiler can spew out 50 lines of incorrect error messages. This problem causes
me to compile, fix the first error message, compile again, fix the first, ...
when there are multiple errors.

-----errors.d-----
char[] concat(char[] x, char[] y) {
        return x ~ y;
}
void delegate() foo;

void func() {
        int j = 5;
        k = 6;

        foo = () {
        };

        mixin(concat("j = ", "7;"));
}
-----
errors.d(8): Error: undefined identifier k
errors.d(10): Error: cannot implicitly convert expression (__dgliteral1) of
type int delegate() to void delegate()
errors.d(13): Error: cannot evaluate concat("j = ","7;") at compile time
errors.d(13): Error: argument to mixin must be a string, not (concat("j =
","7;"))
errors.d(13): Error: cannot evaluate concat("j = ","7;") at compile time
errors.d(13): Error: argument to mixin must be a string, not (concat("j =
","7;"))


-- 



More information about the Digitalmars-d-bugs mailing list