On Thursday, 5 January 2023 at 13:47:24 UTC, Adam D Ruppe wrote:
On Thursday, 5 January 2023 at 13:27:23 UTC, Vijay Nayar wrote:
Why is this error only found when declaring a class in the
unittest?
A unittest is just a special function, it can run code and have
local variables.
classes and structs declared inside it have access to those
local contexts, which it calls the outer function context.
Make the outer class `static` too to lift it out of this and
your error should go away.
Why doesn't the compiler just create the instance with the
correct context pointer? And if it won't, how does one provide
it? I have a template function which creates new instances of a
type that is an argument to the template, and it fails miserably
when the type is a nested class. How do I create such instances?
Dlang is supposed to be "turtles all the way down", but I keep
finding that to be far from reality.