Thread overview
[Issue 7481] New: Compiler should 'soldier on' after template errors
Feb 11, 2012
Don
Feb 11, 2012
Walter Bright
Feb 11, 2012
Don
Feb 11, 2012
Don
Mar 21, 2012
Don
February 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7481

           Summary: Compiler should 'soldier on' after template errors
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2012-02-10 22:03:55 PST ---
At the start of TemplateInstance::semantic is this code:
    if (global.errors)
    {
        //printf("not instantiating %s due to %d errors\n", toChars(),
global.errors);
        if (!global.gag)
        {
            /* Trying to soldier on rarely generates useful messages
             * at this point.
             */
            fatal();
        }
It's a hack, really. This has the effect that after ANY error, any template
instantiation will abort compilation completely. Back in the Bad Old Days, when
the compiler soldiered on, it would spew reams of garbage and then crash. But
now, with all of the ErrorExp improvements, soldiering on does in fact generate
useful error messages.
If there have been errors in the template arguments, obviously it shouldn't
instantiate it, but there's no need to abort compilation completely. More
importantly, notice that it *does* continue if errors are gagged.  Aborting
compilation is hampering our ability to observe what it's doing.
Soldiering on will help make it more robust.

Simple example: this code should generate two errors, one for 'zoo' and one for 'roo'.

int foo(X)(X x) { return 6; }

void main()
{
  foo!(zoo)(5);
  foo!(double)(roo);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7481


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2012-02-10 23:35:18 PST ---
The place I'd like to get is to continue compiling anything that does not depend on something that already failed. We're partway there with the way expressions are evaluated.

For templates, it should try to instantiate one only if its arguments are free of errors.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7481



--- Comment #2 from Don <clugdbug@yahoo.com.au> 2012-02-11 00:20:31 PST ---
(In reply to comment #1)
> The place I'd like to get is to continue compiling anything that does not depend on something that already failed. We're partway there with the way expressions are evaluated.
> 
> For templates, it should try to instantiate one only if its arguments are free of errors.

That's basically what this patch does.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7481



--- Comment #3 from Don <clugdbug@yahoo.com.au> 2012-02-11 00:21:17 PST ---
https://github.com/D-Programming-Language/dmd/pull/708

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7481


bearophile_hugs@eml.cc changed:

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


--- Comment #4 from bearophile_hugs@eml.cc 2012-02-18 07:21:12 PST ---
I'm seeing a huge amount of error messages. It's excessive, please improve the situation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7481


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #5 from Don <clugdbug@yahoo.com.au> 2012-03-21 13:19:21 PDT ---
https://github.com/D-Programming-Language/dmd/commit/b19906ed843b719f3a429ee0c18601296647e340

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