How do you find the struct types in a module? - getting Error: unknown

aliak something at something.com
Thu Feb 13 14:47:05 UTC 2020


Hi,

I'm trying to get a typed list of structs in my current module 
that matches certain criteria. Something like:

module mod;

struct X {}
struct Y {}

alias allTypes = ListOfTypes!mod;

But I'm having a bit of trouble. I have this so far:

template ListOfTypes(alias T) {
     import std.meta;
     enum isStruct(string m) = is(mixin(m) == struct);
     enum types = Filter!(isStruct, __traits(allMembers, T));
     alias toType(string m) = mixin(m);
     alias all = staticMap!(toType, types);
     alias CommandGroupsOf = all;
}

pragma(msg, ListOfTypes!mod);

But that causes an error I've never seen before:

Error: unknown, please file report on issues.dlang.org
onlineapp.d(30,1):        while evaluating `pragma(msg, 
CommandGroupsOf!(mod))`


Any workarounds or maybe insight in to the error?




More information about the Digitalmars-d-learn mailing list