Thread overview
[Issue 9515] UFCS fails with local aliases
Mar 22, 2014
Andrej Mitrovic
Mar 24, 2014
Kenji Hara
Mar 24, 2014
Jonathan M Davis
Mar 24, 2014
Kenji Hara
Mar 24, 2014
Andrej Mitrovic
March 22, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=9515


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2014-03-22 15:06:44 PDT ---
Pull for 6185 did not fix this, so I'm reopening the issue.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 24, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=9515


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2014-03-23 17:15:58 PDT ---
UFCS is not designed to work for local symbols.

http://dlang.org/function#pseudo-member

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 24, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=9515



--- Comment #4 from Jonathan M Davis <jmdavisProg@gmx.com> 2014-03-23 18:28:11 PDT ---
> UFCS is not designed to work for local symbols.

It may very well be an enhancement rather than a bug to get it working with local symbols, but given that we're trying to make it so that there's no real difference between local imports and module-level imports (aside from the scope of the import), I'd say that we should definitely get UFCS working with local imports. It follows the whole "turtles all the way down" principle that we're generally striving for. Certainly, I don't know why we wouldn't implement this. It should simply be a question of someone taking the initiative to get it done rather than whether we should do it or not.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 24, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=9515



--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2014-03-23 18:45:17 PDT ---
(In reply to comment #4)
> > UFCS is not designed to work for local symbols.
> 
[snip]
> Certainly, I don't know why we wouldn't implement this.

My concern case is:

import std.array;
struct MyRange(E) {
    E[] data;

    E front() {
        return data.front;
        // If UFCS could see local symbols, the inner-most 'front' will be
chosen
        // and this line will be rewritten to this.front(data).
    }
}

Note that, in symbol lookup phase function static-ness is not considered. Because functions could be overloaded, and it should be resolved in later phase.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 24, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=9515



--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2014-03-24 06:30:13 PDT ---
(In reply to comment #4)
> > UFCS is not designed to work for local symbols.
> 
> It may very well be an enhancement rather than a bug to get it working with local symbols, but given that we're trying to make it so that there's no real difference between local imports and module-level imports (aside from the scope of the import), I'd say that we should definitely get UFCS working with local imports.

To be precise: local imports work, it's local symbols that don't work.

This works ok:

-----
void main()
{
    import std.array;
    assert([].empty);
}
-----

But this doesn't:

-----
void main()
{
    bool empty(T)(T[]) { return true; }
    assert([].empty);
}
-----

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