[Issue 15225] cannot overload directly aliased function literals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 22 23:34:07 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=15225

Basile-z <b2.temp at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp at gmx.com

--- Comment #4 from Basile-z <b2.temp at gmx.com> ---
A second level of aliasing is required:

    alias lambda1 = (int x) => x;
    alias lambda2 = (string x) => x;
    alias lambda = lambda1;
    alias lambda = lambda2;

    void main()
    {
        auto r0 = lambda(1);
        auto r1 = lambda("a");
    }  

But this should not be the case since, as found in one of the duplicated
reports, this works fine if you replace lambda1/lambda2 by standard functions.

It turns out that the problem is that when doing aliasSemantic() for lambda1,
its `.overnext` member is null. so without the second level of aliasing, the
first match is always used.

It's quite possible that the semantic is done in the wrong order., e.g the call
is resolved before that the overload set is built.

--


More information about the Digitalmars-d-bugs mailing list