Mixin declarations not showing up in ModuleInfo

Daniel Kozak via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 30 00:00:18 PST 2014


On Sunday, 30 November 2014 at 02:10:13 UTC, bitwise wrote:
> In the following program, the output does not contain 
> "SomeClass". Is this a bug?

Maybe yes, as a workaround this works:

module main;
import std.stdio;

template Test()
{
     enum Test = q{
         class SomeClass {
             int n = 123;
         }
     };
}

mixin(Test!());

void main() {

     auto sc = new SomeClass;
     writeln(sc.n);

     foreach(m; ModuleInfo)
     {
         foreach(c; m.localClasses())
         {
             writeln(c.name);
         }
     }
}

Btw. you can use just template, IIRC there is no difference 
between template and mixin template


More information about the Digitalmars-d mailing list