Bug 15830 – UFCS prevents to select a free function when the parameter has a member with the same name
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-24T23:49:00Z
Last change time
2016-10-19T21:09:07Z
Assigned to
nobody
Creator
b2.temp
Comments
Comment #0 by b2.temp — 2016-03-24T23:49:10Z
Maybe DMD could detect that if the call to a member function is invalid this is maybe because it's a call to another function.
struct Foo
{
uint _value;
alias _value this;
void test(){}
}
void test(uint param0, string param1){}
void main()
{
Foo foo;
foo.test(""); // want to call the free function, not the member
}
Comment #1 by ag0aep6g — 2016-03-25T08:51:24Z
(In reply to b2.temp from comment #0)
> Maybe DMD could detect that if the call to a member function is invalid this
> is maybe because it's a call to another function.
>
> struct Foo
> {
> uint _value;
> alias _value this;
> void test(){}
> }
>
> void test(uint param0, string param1){}
>
> void main()
> {
> Foo foo;
> foo.test(""); // want to call the free function, not the member
> }
That would create a case of hijacking [1]: When you later add a method `void test(string)`, then the call would silently change meaning.
[1] http://dlang.org/hijack.html
Comment #2 by b2.temp — 2016-10-19T21:09:07Z
*** Issue 11836 has been marked as a duplicate of this issue. ***