www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3072] New: tuples can't be aliases

reply d-bugmail puremagic.com writes:

           Summary: tuples can't be aliases
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: shro8822 vandals.uidaho.edu


import std.stdio;

template Ta(alias t){void Tfn(){writef(t);}}
template Tt(t...){void Tfn(){writef(t);}}

struct S
   int i; int j; int k;
   mixin Ta!(i);  // passes
   mixin Tt!(i,j);  // fails

this causes issues for mixin function that are supposed to work on a subset of
the members of the enclosing type. The string mixin work around is just flat

I don't think the spec says this shouldn't work so I'm calling it a bug.

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 16 2009
parent d-bugmail puremagic.com writes:

Rob Jacques <sandford jhu.edu> changed:

           What    |Removed                     |Added
           Keywords|                            |accepts-invalid,
                   |                            |rejects-valid, spec
                 CC|                            |sandford jhu.edu
            Version|1.00                        |D1 & D2
            Summary|tuples can't be aliases     |tuples can't be aliases (
                   |                            |except when the aliases are
                   |                            |templates. )

--- Comment #1 from Rob Jacques <sandford jhu.edu> 2010-10-20 10:59:44 PDT ---
In general template tuples can't contain alias template parameters but it
appears that there is an exception to this rule when the parameter is itself a

DMD 2.049

T foo(T)(T t) { return t; }
template map1(fun...) {
    enum map1 = 42;
template map2(T, U...) {
    static if(U.length > 0) enum map2 = map2!(U);
    else                    enum map2 = 42;

void main() {
    auto x = map1!(char,foo);  // compiles
    auto y = map2!(char,foo);  // doesn't compile
    auto z = map1!(char,map1); // compiles
    auto w = map2!(char,map1); // doesn't compile

I've added the accepts-invalid, rejects-valid and spec keywords, since tuples
of aliases should either work or not-work and the behavior should be documented
in the spec. I'd lean towards not-work, since tuples of aliases seem to be
buggy (i.e. Issue 5087) not to mention that alias parameters are buggy(i.e.
issue 5082)

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