digitalmars.D.bugs - template/nested functions bug
- John C (20/20) Sep 30 2005 This code produces the following error: "function Test.ensure is a neste...
- =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= (12/37) Oct 02 2005 -----BEGIN PGP SIGNED MESSAGE-----
This code produces the following error: "function Test.ensure is a nested function and cannot be accessed from testMethod". (DMD 0.133 Windows XP SP2) template toArray(T) { T[] toArray(T[] params ...) { return params.dup; } } class Test { private static int[] values_; static void testMethod() { ensure(); } static void ensure() { if (values_.length == 0) values_ = .toArray!(int)(1, 2, 3); } } Obviously, ensure() isn't a nested function. The error can be eliminated by surrounding the code in ensure() in block. Looks like the parser is mismatching braces?
Sep 30 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 John C schrieb:This code produces the following error: "function Test.ensure is a nested function and cannot be accessed from testMethod". (DMD 0.133 Windows XP SP2) template toArray(T) { T[] toArray(T[] params ...) { return params.dup; } } class Test { private static int[] values_; static void testMethod() { ensure(); } static void ensure() { if (values_.length == 0) values_ = .toArray!(int)(1, 2, 3); } } Obviously, ensure() isn't a nested function. The error can be eliminated by surrounding the code in ensure() in block. Looks like the parser is mismatching braces?Added to DStress as http://dstress.kuehne.cn/run/i/inline_15_A.d http://dstress.kuehne.cn/run/i/inline_15_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDQEbf3w+/yD4P9tIRAiZPAJ0YFLZ3vFGsaEkwkBuaDNftM741dQCgp+/v Ju++M+Rk/UFHw6hdIEsToBo= =P739 -----END PGP SIGNATURE-----
Oct 02 2005