D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13602 - Painfully long bad diagnostic on mismatched parenthesis
Summary: Painfully long bad diagnostic on mismatched parenthesis
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 minor
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2014-10-10 23:00 UTC by Dmitry Olshansky
Modified: 2020-09-29 09:46 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dmitry Olshansky 2014-10-10 23:00:39 UTC
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
Comment 1 yebblies 2014-12-02 14:06:58 UTC
Why exactly is this critical?
Comment 2 RazvanN 2020-09-29 09:46:06 UTC
This has been fixed in master.