static function and access frame

Alex sascha.orlov at gmail.com
Tue Jan 23 22:48:36 UTC 2018


On Tuesday, 23 January 2018 at 22:33:31 UTC, 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

the other fun is meant to be static :)
so, the fun inside T.


More information about the Digitalmars-d-learn mailing list