www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7780] New: Template mixin'd members do not properly overload

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

           Summary: Template mixin'd members do not properly overload
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simen.kjaras gmail.com



PDT ---
mixin template A( ) {
    template C( int n : 0 ) {
        int C = 0;
    }
}

mixin template B( ) {
    template C( int n : 1 ) {
        int C = 1;
    }
}

class Foo {
    mixin A!( );
    mixin B!( );
}

void main( ) {
    assert( Foo.C!0 == 0 );
}

foo.d(19): Error: __overloadset isn't a template

Or (without the wrapping class):

foo.d(17): Error: template instance C!(0) ambiguous template declaration
foo.B!().C(int n : 1) and foo.A!().C(int n : 0)

The two versions of C here introduced could clearly coexist and be referred to
as Foo.C!0 and Foo.C!1.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 25 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7780


Shire <degener_trash mail.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |degener_trash mail.ru



Also trivial methods hides mixin overloads:

static struct A {
  // to generate a lot of repeating overloads
  // mixin will be good
  mixin template _bind(T, string S) {
    string bind(T var) { return S; }
  }
  mixin _bind!(short, "Short");
  mixin _bind!(int, "Int");
  string bind(long var) { return "Long"; }
  string bind(double var) { return "Double"; }
}

A a;
short s; int i; long l; double d;
string all = a.bind(s) ~ a.bind(i) ~ a.bind(l) ~ a.bind(d);
assert(all == "ShortIntLongDouble"); // fail with "LongLongLongDouble"
// mixin scopes is invisible for bind() overloading

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7780




PDT ---

 Also trivial methods hides mixin overloads:
 
[snip] Actually, that is quite clearly described under template mixins[1]: "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" I agree it would be nice to have a way to not have them override, but I can absolutely see why one might want that rule. [1]: http://dlang.org/template-mixin.html -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7780


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid




[snip]
 
 foo.d(19): Error: __overloadset isn't a template
 
 Or (without the wrapping class):
 
 foo.d(17): Error: template instance C!(0) ambiguous template declaration
 foo.B!().C(int n : 1) and foo.A!().C(int n : 0)
 
 The two versions of C here introduced could clearly coexist and be referred to
 as Foo.C!0 and Foo.C!1.
https://github.com/D-Programming-Language/dmd/pull/1660 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7780




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f729d78d895a78a426de229c22cf3bc2174c142b
fix Issue 7780 - Template mixin'd members do not properly overload

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


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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