http://d.puremagic.com/issues/show_bug.cgi?id=2514

           Summary: indexing error in struct.tupleof[i]
           Product: D
           Version: 1.036
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzi...@digitalmars.com
        ReportedBy: shro8...@vandals.uidaho.edu


template Foo(T, uint n = 0)
{
   static if(T.tupleof.length <= n) const char[] Foo = "";
   else const char[] Foo = typeof(T.tupleof[n]).stringof ~ " " ~ Foo!(T,n+1);
}

import std.stdio;
void main()
{
  writef("%d, %s\n", __VERSION__, Foo!(S)); /// generates "int, int, int"
}

struct S { int i; uint j; float k; }

for this, the following is a work around:

-   else const char[] Foo = typeof(T.tupleof[n]).stringof ~ " " ~ Foo!(T,n+1);
+   else const char[] Foo = typeof(T.tupleof)[n].stringof ~ " " ~ Foo!(T,n+1);


-- 

Reply via email to