www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - strange compilation error

reply "Jack Applegame" <japplegame gmail.com> writes:
This fails to compile
http://dpaste.dzfl.pl/e9a90e808af4
Mar 09 2014
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
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); }; } Bye, bearophile
Mar 09 2014
next sibling parent "Jack Applegame" <japplegame gmail.com> writes:
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); }; } Bye, bearophile
thanks
Mar 09 2014
prev sibling parent reply "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
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...
Mar 09 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
Marc Schütz:

 The error message is confusing, though. main is not a nested 
 function, rather it's a function _containing_ a nested class...
If you don't like the error message then I suggest to open in Bugzilla a diagnostic bug report (if you want with "minor" importance). Bye, bearophile
Mar 09 2014
prev sibling parent "Kenji Hara" <k.hara.pg gmail.com> writes:
On Sunday, 9 March 2014 at 11:21:19 UTC, Jack Applegame wrote:
 This fails to compile
 http://dpaste.dzfl.pl/e9a90e808af4
It's a compiler bug. https://d.puremagic.com/issues/show_bug.cgi?id=12334 https://github.com/D-Programming-Language/dmd/pull/3371 Kenji Hara
Mar 09 2014