strange compilation error

Marc Schütz" <schuetzm at gmx.net> Marc Schütz" <schuetzm at gmx.net>
Sun Mar 9 11:15:10 PDT 2014


On Sunday, 9 March 2014 at 12:21:18 UTC, bearophile wrote:
> Jack Applegame:
>
>> This fails to compile
>> http://dpaste.dzfl.pl/e9a90e808af4
>
> There are various ways to avoid this problem, using static 
> classes/structs is one of the simplest:
>
> void main() {
>     static class B {
>         int a;
>         this(int aa) { a = aa; }
>     }
>     auto foo = {
>         return new B(1);
>     };
> }

The error message is confusing, though. main is not a nested 
function, rather it's a function _containing_ a nested class...


More information about the Digitalmars-d-learn mailing list