lambdas and function literals in classes

bearophile bearophileHUGS at lycos.com
Tue Jul 9 04:16:38 PDT 2013


Dicebot:

> So this has something to do with _initialization_ of class 
> members with delegates/lambdas, not their very existence.


So is it worth adding this diagnostic bug report in Bugzilla?


class Foo {
     void delegate() dg1;
     void delegate() dg2 = delegate(){};
     this() {
         this.dg1 = (){};
     }
}
void main() {
     auto f = new Foo;
}



DMD 2.064alpha gives:

temp.d(3): Error: delegate temp.Foo.__dgliteral1 function 
literals cannot be class members
temp.d(3): Error: cannot implicitly convert expression 
(__dgliteral1) of type _error_ delegate() to void delegate()


Bye,
bearophile


More information about the Digitalmars-d-learn mailing list