Thread overview
[Issue 3790] New: [OOP] constructor of child class cannot pass arguments into parent constructor
Feb 10, 2010
iorlas
Feb 10, 2010
iorlas
Nov 12, 2010
Don
Feb 06, 2011
Brad Roberts
February 10, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3790

           Summary: [OOP] constructor of child class cannot pass arguments
                    into parent constructor
           Product: D
           Version: 2.041
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: denis.tomilin@gmail.com


--- Comment #0 from iorlas <denis.tomilin@gmail.com> 2010-02-09 18:16:32 PST ---
Constructor of child class cannot pass arguments into parent constructor. See the example:

class A{
 final this(int a=0){
  writeln(a);
 }
}
class B:A{
}

B b = new B(); //prints 0
B b2 = new B(2); //throws an error "expected 0 arguments, not 1..."

As we can see, logic is normal, but not in dmd. This bug creates a new bug:

class A{
 final this(int a=0){
  writeln(a);
 }
}
class B:A{
 this(int a=0){ //compiler perfectly, but parent constructor marked as "final"
  super(a);
 }
}

It might be not a hard problem, but it will be good for my project to create a logical, nice-look code.

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



--- Comment #1 from iorlas <denis.tomilin@gmail.com> 2010-02-09 20:05:05 PST ---
Also, if we dont give argument a default value, we get an error:
Error: constructor main.B.this no match for implicit super() call in
constructor
As i think, somebody thinks in different way with a lot of stones and problems
=/

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
           Severity|blocker                     |enhancement


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-11-12 05:03:07 PST ---
This bug report has two issues:
(1) an enhancement request: allow constructors to be inherited.
and
(2) an accepts-invalid bug: 'final this()' is accepted, even though this() is
_always_ final.

Downgrading to enhancement.

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


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86_64                      |x86


--- Comment #3 from Brad Roberts <braddr@puremagic.com> 2011-02-06 15:40:22 PST ---
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.

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