Thread overview
[Issue 3127] New: 'unreachable code' warning destroys delegate literal type inference
Jul 03, 2009
Don
Feb 01, 2010
Don
July 02, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3127

           Summary: 'unreachable code' warning destroys delegate literal
                    type inference
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


D1 and D2. Compile with -w.
===========
void bar(real delegate(real) f) {    }

void foo() {
    return;
    assert(0);
}

void main() {
    bar( (real x){ return x; });
}
===========
Output with DMD1.045:
C:\dev>dmd -w bug
warning - bug.d(5): Error: statement is not reachable
bug.d(9): Error: function bug.bar (real delegate(real)) does not match
parameter
 types (int delegate(real x))
bug.d(9): Error: cannot implicitly convert expression (__dgliteral1) of type
int
 delegate(real x) to real delegate(real)

On DMD2.030, the type is 'void' instead:
C:\dev>dmd -w bug
warning - bug.d(5): Error: statement is not reachable
bug.d(9): Error: function bug.bar (real delegate(real) f) does not match
paramet
er types (void delegate(real x))
bug.d(9): Error: cannot implicitly convert expression (__dgliteral1) of type
voi
d delegate(real x) to real delegate(real)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3127


Jarrett Billingsley <jarrett.billingsley@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jarrett.billingsley@gmail.c
                   |                            |om




--- Comment #1 from Jarrett Billingsley <jarrett.billingsley@gmail.com>  2009-07-02 08:52:35 PDT ---
I'm not sure if this is valid, only because DMD treats warnings as errors, and the code wouldn't compile anyway even if it didn't spit out the bogus subsequent error.  I've had it spit out dumb semantic errors like this after other errors, and errors after the first are usually not to be trusted anyway..

It's kind of like how DMD sets the type of invalid expressions to 'int' and then marches on, giving you all sorts of dumb errors that don't actually mean anything.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 03, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3127





--- Comment #2 from Don <clugdbug@yahoo.com.au>  2009-07-03 01:09:08 PDT ---
>I'm not sure if this is valid, only because DMD treats warnings as errors, and
the code wouldn't compile anyway even if it didn't spit out the bogus subsequent error.

If it were in the same function, I would agree. But in this case, I can't see _any_ reason for the error to propagate from one function to an unrelated one. It's an indication that something's wrong.

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


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

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


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2010-02-01 00:01:03 PST ---
Fixed in D1 in DMD1.046, and in D2, sometime before D2.035.

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