On 2019-10-15 09:06, John Colvin wrote:
And all the other ones in my example that access members without an
instance that also compile?
There's something pretty strange about the rules here.
The thing is that it should be possible to access a non-static member
without an instance because it's possible to manually construct a delegate:
class S
{
int a;
int e() @property { return a; }
}
void foo()
{
int function() f = &S.e; // this compiles
int delegate() dg;
S s;
dg.ptr = &s;
dg.funcptr = f;
}
struct C
{
void bar()
{
int function() f = &S.e; // this fails for some reason but
should compile
}
}
So the expression `S.e` should compile, because it can be part of a
large expression, i.e. `&S.e`, which should compile.
The strange thing is that it fails to compile inside `C`. But if `bar`
is changed to a static method it compiles again.
--
/Jacob Carlborg