http://d.puremagic.com/issues/show_bug.cgi?id=8788

           Summary: The super constructor call can be prevented by
                    mentioning "return".
           Product: D
           Version: D1 & D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: david.ecka...@sociomantic.com


--- Comment #0 from David Eckardt <david.ecka...@sociomantic.com> 2012-10-09 
07:20:46 PDT ---
Mentioning a "return" prevents DMD from rejecting code where a constructor has
an explicit super() call which is done conditionally or not at all. Also it is
possible to return or throw before doing the super() call.
This example code compiles although it should be rejected:
---
class A { this ( ) { } }

class B : A
{
    this ( )
    {
        return;
        super();
    }

    this(int x)
    {
        try
        {
            throw new Exception;
            super();
        }
        catch ( ) { }
    }

    this(float f)
    {
        if (x == 3)
            return;
        else
            super();
    }


    this(char c)
    {
        if (c == 'x')
            super();
        else
            return;
    }
}
---
However, if the "return" statement in the second and third constructor is
omitted, the compile error is triggered correctly.

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

Reply via email to