Thread overview
[Issue 8228] New: Mixin template can't add constructor to class
Jun 11, 2012
Andrej Mitrovic
Aug 21, 2013
John Colvin
Aug 21, 2013
Andrej Mitrovic
Aug 21, 2013
Andrej Mitrovic
June 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8228

           Summary: Mixin template can't add constructor to class
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-06-11 15:22:20 PDT ---
mixin template Root()
{
    this(int x) { }
    void test() { }
}

class Foo
{
    mixin Root;
    this()
    {
        test();   // OK
        this(1);  // FAIL
    }
}

void main() { }

It's ok to add virtual methods but not constructors. This has to be a bug..

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


John Colvin <john.loughran.colvin@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.loughran.colvin@gmail.
                   |                            |com


--- Comment #1 from John Colvin <john.loughran.colvin@gmail.com> 2013-08-21 23:16:42 BST ---
(In reply to comment #0)
> mixin template Root()
> {
>     this(int x) { }
>     void test() { }
> }
> 
> class Foo
> {
>     mixin Root;
>     this()
>     {
>         test();   // OK
>         this(1);  // FAIL
>     }
> }
> 
> void main() { }
> 
> It's ok to add virtual methods but not constructors. This has to be a bug..

sadly, it's not a bug. template mixins create a scope and there's no overload resolution between it and it's enclosing scope.


We should really have a way of doing a full mixin without resorting to strings.

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



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-08-21 15:26:31 PDT ---
*** Issue 9851 has been marked as a duplicate of this issue. ***

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


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |enhancement


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