On 1/23/18 5:33 PM, Ali Çehreli wrote:
On 01/23/2018 01:51 PM, Alex wrote:
> Ok, I'm quite sure, I overlooked something.
>
> First version, working
>
> [code]
> void main()
> {
> auto s = S();
> auto t = T!s();
> t.fun;
> }
> struct S { void fun(){} }
> struct T(alias s){ auto fun() { s.fun; } }
> [/code]
>
> Now, the fun method of struct T has to become static and the problems
> begin:
> Error: static function app.main.T!(s).T.fun cannot access frame of
> function D main
Good news: Works at least with 2.078 as it should:
void main()
{
auto s = S();
auto t = T!s();
t.fun;
}
struct S { static void fun(){} }
struct T(alias s){ auto fun() { s.fun; } }
Ali
No:
void main()
{
auto s = S();
auto t = T!s();
t.fun;
}
struct S { void fun(){} }
struct T(alias s){ static fun() { s.fun; } }
Fails in 2.078.
I don't know the reason. You would think that accessing s would be
relative to T.fun's stack frame, and have nothing to do with an instance
of T.
I would file a bug, and see what the compiler devs say.
-Steve