[Issue 8983] Overload introduced behind mixin template can't be called from another overload

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 8 14:54:35 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8983


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com


--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> 2012-11-08 14:54:35 PST ---
This actually isn't a bug. Inserting a template mixin creates a new nested
scope, and names not in that nested scope override the ones in it.

Your code can be made to work in two ways. But first we need to give a name to
the nested scope:

    mixin MixOverload;

becomes:

    mixin MixOverload nn;

Now, the mixin template names can be prefixed with nn:

    void test(int x)
    {
        nn.test(x, 1);    // call the overload defined in the mixin
    }

which works. Alternatively, the nested scope can be aliased into the current
scope with:

    alias nn.test test;

and now:

    void test(int x)
    {
        test(x, 1);    // call the overload defined in the mixin
    }

will work, as aa.test will be overloaded with test.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list