Shouldn't __traits return Tuples?

Trass3r mrmocool at gmx.de
Wed Apr 1 11:54:12 PDT 2009


Trass3r schrieb:
>>     enum members = __traits(allMembers, Class);
>>     foreach (i; Sequence!(members.length))
>>     {
>>         static if (isFunction!(Class, members[i]))
>>         {
>>             foreach (j; __traits(getVirtualFunctions, Class,
>> members[i]))
>>                 writefln(members[i], ": ", typeid(typeof(j)));
>>         }
>>     }
>> }
> 
> Yeah extreeemely buggy. dmd also crashes if that enum members is changed 
> to const members or invariant members.
> 


Ok, narrowed that down to:
template Sequence(size_t count, size_t index = 0)
{
    static if (index < count)
       alias Tuple!(index, Sequence!(count, index + 1)) Sequence;
}

void main()
{
	const members = ["foo", "bar"];
	foreach (i; Sequence!(members.length))
	{
		writefln(members[i]);
	}
}

Also crashes. Changing to auto or even enum (i mean enum is also 
constant, so ???)
yields:
Error: variable main2.main.i voids have no value



More information about the Digitalmars-d mailing list