Inner function overload bug?

Era Scarecrow rtcvb32 at yahoo.com
Wed Jan 9 03:52:07 PST 2013


On Wednesday, 9 January 2013 at 10:53:53 UTC, Philippe Sigaud 
wrote:
> On Wed, Jan 9, 2013 at 1:53 AM, Andrej Mitrovic wrote:
>> On 1/9/13, bearophile wrote:
>>> If you define an inner static struct, its static methods can 
>>> call each other freely.
>>
>> You can also use a mixin template:
>>
>> mixin template S()
>> {
>>     void test(ref int x) { x = test(); }
>>     int test() { return 1; }
>> }
>>
>> void main()
>> {
>>     mixin S;
>>
>>     int x;
>>     test(x);
>>     assert(x == 1);
>> }
>
> That's weird. Why does that work? Directly pasting the mixin 
> content in main() does not compile, right?

  I can only assume if it does work, that the mixin template has 
it's own scope that enables the overloading. If you can't do it 
with one, you shouldn't be allowed to do it with the other.

  Overloading within nested functions is likely a rare use case.



More information about the Digitalmars-d-learn mailing list