www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20648] New: static foreach over allMembers of module doesn't

https://issues.dlang.org/show_bug.cgi?id=20648

          Issue ID: 20648
           Summary: static foreach over allMembers of module doesn't seem
                    to work
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

This should list all the structs in the module:

----------------------
module my_module;

struct Wow {}

template ScrapeStructs(Tys...)
{
    import std.meta : AliasSeq;
    static if (Tys.length == 0)
        alias ScrapeStructs = AliasSeq!();
    else static if (is(Tys[0] == struct))
        alias ScrapeStructs = AliasSeq!(Tys[0], ScrapeStructs!(Tys[1 .. $]));
    else
        alias ScrapeStructs = ScrapeStructs!(Tys[1 .. $]);
}

alias AllStructs = ScrapeStructs!(__traits(allMembers, my_module));

pragma(msg, AllStructs); // ()
pragma(msg, is(Wow == struct)); // true
----------------------

But it doesn't...

--
Mar 08