September 30, 2005 template/nested functions bug | ||||
---|---|---|---|---|
| ||||
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? |
October 02, 2005 Re: template/nested functions bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C Attachments: | 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 |
Copyright © 1999-2021 by the D Language Foundation