Inner function overload bug?
dennis luehring
dl.soluz at gmx.net
Wed Jan 9 06:02:15 PST 2013
Am 09.01.2013 14:21, schrieb Philippe Sigaud:
> On Wed, Jan 9, 2013 at 12:52 PM, Era Scarecrow <rtcvb32 at yahoo.com> wrote:
>
>>> 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.
>
> That must be it. mixin can have names (mixin TemplateName AliasName;)
> which the functions as a disambiguator.
> I don't have access to a D compiler right now. Does this work?:
>
>
> void main()
> {
> {
> void test(ref int x) { x = test(); }
> int test() { return 1; }
> }
> int x;
> test(x);
> assert(x == 1);
> }
>
>
>
>> Overloading within nested functions is likely a rare use case.
>
> I hit it while trying to change a module from struct+methods to purely
> functions everywhere, to see if there were any efficiency difference.
>
http://dpaste.dzfl.pl/ ist your friend
Compilation output:
/home/c250/c278.d(4): Error: function c278.main.test (ref int x) is not
callable using argument types ()
/home/c250/c278.d(4): Error: expected 1 function arguments, not 0
/home/c250/c278.d(5): Error: declaration test is already defined
/home/c250/c278.d(8): Error: undefined identifier test
More information about the Digitalmars-d-learn
mailing list