www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3393] New: illegal to refer to 'this' implicitly or explicitly

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3393

           Summary: illegal to refer to 'this' implicitly or explicitly
           Product: D
           Version: 2.032
          Platform: x86
               URL: http://www.digitalmars.com/d/2.0/class.html#Constructo
                    r
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid, spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dfj1esp02 sneakemail.com



07:44:56 PDT ---
Spec reads: 3. It is illegal to refer to this implicitly or explicitly prior to
making a constructor call. Although it's allowed.

---
class A
{
    int a;
    this(){ M(); this(1); }
    this(int b){ a=b; }
    void M(){ writeln("A.M"); }
}

class B:A
{
    int b;
    this(){ M(); super(); b=5; }
    override void M(){ writeln("B.M ",b); }
}

int main()
{
    auto b=new B();
    b.M();
    return 0;
}
---

output is
---
B.M 0
B.M 0
B.M 5
---

We see how virtual method is called prior to constructor calls and overridden
method from derived class is called from the constructor of the base class
(called on not yet constructed object).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 13 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3393


nfxjfg gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg gmail.com
            Version|2.032                       |D1 & D2



Same problem with D1.

Also see bug 5056.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 16 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3393


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|spec                        |
                 CC|                            |bugzilla digitalmars.com



01:31:18 PST ---
Compiler bug, not a spec issue.

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