www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9053] New: Can't overload functions with mixin

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

           Summary: Can't overload functions with mixin
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: freeslave93 gmail.com



mixin template MyMixin()
{
    void foo(int)
    {

    }
}

struct A
{
    void foo()
    {

    }
    mixin MyMixin;
}

int main(string[] args)
{
    A a;
    a.foo(5);
    return 0;
}

Error: function hello.A.foo () is not callable using argument types (int)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9053


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |timon.gehr gmx.ch
         Resolution|                            |INVALID



That is how it is supposed to work.

"Mixin Scope
The declarations in a mixin are ‘imported’ into the surrounding scope. If
the
name of a declaration in a mixin is the same as a declaration in the
surrounding scope, the surrounding declaration overrides the mixin one"

dlang.org/template-mixin.html

You can use a string mixin to generate overloads.

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