www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8684] New: Missing ')' in argument list creates a sea of error messages

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8684

           Summary: Missing ')' in argument list creates a sea of error
                    messages
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au



int foo(int n, int m)
{
    int x = foo( 5, m;
    for (int q=0; q<10; ++q){
       ++q;
    }
    return  2;
}

The error is a single missing ')'. But the compiler spits an error for each
extra token in the file. Probably, as soon as it hits an unexpected ;, it
should assume that it has reached the end of the argument list.
In reality this situation often happens in situations where the last parameter
is a function call, and parentheses are mismatched:
foo(5, foo(3, foo(7,6));

----------
r.d(4): Error: found ';' when expecting ',' following argument
r.d(5): Error: expression expected, not 'for'
r.d(5): Error: found 'q' when expecting '.' following int
r.d(5): Error: found '=' when expecting identifier following 'int.'
r.d(5): Error: found '0' when expecting ',' following argument
r.d(5): Error: expression expected, not ';'
r.d(5): Error: found 'q' when expecting ',' following argument
r.d(5): Error: expression expected, not '<'
r.d(5): Error: found '10' when expecting ',' following argument
r.d(5): Error: expression expected, not ';'
r.d(5): Error: found 'q' when expecting ',' following argument
r.d(5): Error: expression expected, not ')'
r.d(5): Error: found '{' when expecting ',' following argument
r.d(6): Error: found ';' when expecting ',' following argument
r.d(7): Error: expression expected, not '}'
r.d(8): Error: found 'return' when expecting ',' following argument
r.d(8): Error: found ';' when expecting ',' following argument
r.d(9): Error: expression expected, not '}'
r.d(12): Error: found 'EOF' when expecting ',' following argument
r.d(12): Error: found 'EOF' when expecting ')' following argument list

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8684


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



Some cases that look related (but I don't know if they are actually similar).

From the thread:
http://forum.dlang.org/thread/osnevnwnshreoaudleep forum.dlang.org

In the following examples I'd like the D compiler to give more focused error
messages.

----------------------

int main() {
     for (int i = 0, i < 10, i++) {
         // do something
     }
     return 0;
}


temp.d(2): Error: semicolon expected, not '<'
temp.d(2): Error: expression expected, not '<'
temp.d(2): Error: found '10' when expecting ';' following for condition
temp.d(2): Error: expression expected, not ','
temp.d(2): Error: found 'i' when expecting ')'
temp.d(2): Error: expression expected, not ')'
temp.d(2): Error: found '{' when expecting ';' following statement
temp.d(5): Error: Declaration expected, not 'return'
temp.d(6): Error: unrecognized declaration

----------------------

void main() {
     foreach (i, 0 .. 10) {}
}


temp.d(2): Error: basic type expected, not 0
temp.d(2): Error: no identifier for declarator int
temp.d(2): Error: found '0' when expecting ';'
temp.d(2): Error: expression expected, not '..'
temp.d(2): Error: found '10' when expecting ')'
temp.d(2): Error: found ')' instead of statement
temp.d(3): Error: unrecognized declaration

---------------------------------

void main() {
     int[10] data;
     foreach (i, x, data) {}
}



temp.d(3): Error: no identifier for declarator data
temp.d(3): Error: found ')' when expecting ';'
temp.d(4): Error: found '}' when expecting ')'
temp.d(4): Error: found 'EOF' instead of statement
temp.d(4): Error: found 'EOF' when expecting '}' following compound statement

---------------------------------

void main() {
     int[10] data;
     foreach (i; x; data) {}
}


temp.d(3): Error: found ';' when expecting ')'
temp.d(3): Error: found ')' when expecting ';' following statement

---------------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 12 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8684




---------------------------------

void main() {
   int value = 0;

   while (value < 10) do {
     // do something
     value++;
   }
}


temp.d(8): Error: found '}' when expecting 'while'
temp.d(8): Error: found 'EOF' when expecting '('
temp.d(8): Error: expression expected, not 'EOF'
temp.d(8): Error: found 'EOF' when expecting ')'
temp.d(8): Deprecation: do-while statement without terminating ; is deprecated
temp.d(8): Error: found 'EOF' when expecting '}' following compound statement

---------------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 12 2012