[Issue 1364] New: 2.003 traits within loop
BCS
ao at pathlink.com
Mon Jul 23 10:31:05 PDT 2007
Reply to d-bugmail at puremagic.com,
> http://d.puremagic.com/issues/show_bug.cgi?id=1364
>
> Summary: 2.003 traits within loop
> Product: D
> Version: 2.002
> Platform: PC
> OS/Version: Windows
> Status: NEW
> Severity: normal
> Priority: P2
> Component: DMD
> AssignedTo: bugzilla at digitalmars.com
> ReportedBy: Daniel919 at web.de
> import std.stdio;
>
> class D
> {
> this() { }
> ~this() { }
> void foo() { }
> int foo(int) { return 0; }
> int x;
> }
> void main()
> {
> D d = new D;
> foreach (t; __traits(allMembers, typeof(d)))
> writefln(typeid(typeof(__traits(getMember, d, t))));
> }
> (17): Error: string expected as second argument
>
The issue might be that the foreach is a run time foreach and the inner __traits
needs a string literal. Some sort of array-to-tuple magic is needed. This
might end up looing somthing like this:
mixin(CTFEarrayToTuple(__traits(allMembers, typeof(d))))
More information about the Digitalmars-d-bugs
mailing list