Forward Reference Error in unittests

rbscott tjonsies818 at yahoo.com
Tue Dec 3 08:48:47 UTC 2019


Hello,

I was using a unittest to test a mixin that creates a class 
inside of a struct and I ran into an unexpected error. I removed 
all of the templates and simplified it down to this case:

unittest {
   static struct SimpleStruct {
     static class NestedClass {
       private SimpleStruct value;
     }
   }
}

For some reason this generates a forward reference error, but if 
I take the exact same code and declare it outside of a unittest 
it goes away. If it runs in a version block instead of a unittest 
block it also works? I think declaring structs is OK in 
unittests? I tested this with:

unittest {
   static struct SimpleStruct {
     static class NestedClass {
       private int value;
     }
   }
}

And this works fine. Any ideas about why this doesn't work in a 
unittest?

Thanks!
rbscott



More information about the Digitalmars-d mailing list