Thread overview
[Issue 7780] New: Template mixin'd members do not properly overload
Mar 25, 2012
Simen Kjaeraas
May 19, 2012
Shire
May 19, 2012
Simen Kjaeraas
Jul 04, 2013
Kenji Hara
Jul 17, 2013
Kenji Hara
March 25, 2012
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


--- Comment #0 from Simen Kjaeraas <simen.kjaras@gmail.com> 2012-03-25 15:21:31 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: -------
May 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7780


Shire <degener_trash@mail.ru> changed:

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


--- Comment #1 from Shire <degener_trash@mail.ru> 2012-05-19 01:16:59 PDT ---
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
http://d.puremagic.com/issues/show_bug.cgi?id=7780



--- Comment #2 from Simen Kjaeraas <simen.kjaras@gmail.com> 2012-05-19 03:01:00 PDT ---
(In reply to comment #1)
> 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: -------
July 04, 2013
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


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-04 05:55:37 PDT ---
(In reply to comment #0)
[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: -------
July 17, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7780



--- Comment #4 from github-bugzilla@puremagic.com 2013-07-16 18:35:49 PDT ---
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: -------
July 17, 2013
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: -------