Mixin templates accessing mixed out scope
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Sep 12 10:11:04 PDT 2015
On Saturday 12 September 2015 16:30, Ali Çehreli wrote:
> Reduced:
[...]
> Error: type SingleStore is not an expression
Reduced further:
----
class MyStore
{
class SingleStore
{
static void New() // Removing 'static' compiles
{
new SingleStore();
}
}
}
----
And now the problem can be spotted:
SingleStore is a nested class. That means, instances of it are bound to
MyStore instances. But New is static, so it doesn't have a MyStore to which
it could attach the `new SingleStore`.
That error message is pretty awful. I filed an issue:
https://issues.dlang.org/show_bug.cgi?id=15049
As for a fix: I guess SingleStore isn't supposed to be a nested class. Mark
it static then.
More information about the Digitalmars-d-learn
mailing list