The four calls should work, but #1 doesn't work. struct S { int v; alias v this; } void foo(ref int n){} void main() { auto s = S(1); // variable s is lvalue, so // alias this expanded expression s.v is also lvalue and matches to ref. foo(s); // 1.NG -> OK s.foo(); // 2.OK, ufcs foo(s.v); // 3.OK s.v.foo(); // 4.OK, ufcs }
https://github.com/D-Programming-Language/dmd/pull/890
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ec6a33778767db278613b058641c849ea7625b43 fix Issue 7945 - alias this doesn't work on function ref parameter
*** Issue 7991 has been marked as a duplicate of this issue. ***