www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13602] New: Painfully long bad diagnostic on mismatched

https://issues.dlang.org/show_bug.cgi?id=13602

          Issue ID: 13602
           Summary: Painfully long bad diagnostic on mismatched
                    parenthesis
           Product: D
           Version: unspecified
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: critical
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: dmitry.olsh gmail.com

The compiler must be able to recover once ';' is seen.
Instead goes off in cascading failure state, where everything after badly
balanced expression is wrong.

Snippent: 

unittest
{
    with(factory){
 // !!! Notice unbalanced parenthesis !!!
        auto matcher = seq(name("First", star(value(4)));
        assert(matcher(records));
        assert(records == [ Rec("Last", 8) ]);
    }
}


/// Generic matcher interface
interface Matcher(Stream)
    if(isForwardRange!Stream)
{

}

// The more code the longer is the insane diagnostic

/// Generic matcher interface
interface Matcher(Stream)
    if(isForwardRange!Stream)
{

}

/// Generic matcher interface
interface Matcher(Stream)
    if(isForwardRange!Stream)
{

}

/// Generic matcher interface
interface Matcher(Stream)
    if(isForwardRange!Stream)
{

}


Compiler's output:

/home/dmitry/bug.d(5): Error: found ';' when expecting ','
/home/dmitry/bug.d(6): Error: found ';' when expecting ','
/home/dmitry/bug.d(7): Error: found ';' when expecting ','
/home/dmitry/bug.d(8): Error: expression expected, not '}'
/home/dmitry/bug.d(9): Error: found '}' when expecting ','
/home/dmitry/bug.d(13): Error: expression expected, not 'interface'
/home/dmitry/bug.d(13): Error: found 'Matcher' when expecting ','
/home/dmitry/bug.d(14): Error: found 'if' when expecting ','
/home/dmitry/bug.d(22): Error: found 'interface' when expecting ','
/home/dmitry/bug.d(23): Error: found 'if' when expecting ','
/home/dmitry/bug.d(29): Error: found 'interface' when expecting ','
/home/dmitry/bug.d(30): Error: found 'if' when expecting ','
/home/dmitry/bug.d(36): Error: found 'interface' when expecting ','
/home/dmitry/bug.d(37): Error: found 'if' when expecting ','
/home/dmitry/bug.d(40): Error: found 'EOF' when expecting ','
/home/dmitry/bug.d(40): Error: found 'EOF' when expecting ')'
/home/dmitry/bug.d(40): Error: semicolon expected following auto declaration,
not 'EOF'
/home/dmitry/bug.d(40): Error: found 'EOF' when expecting '}' following
compound statement
/home/dmitry/bug.d(40): Error: found 'EOF' when expecting '}' following
compound statement

--
Oct 10 2014