[Issue 17879] UFCS can enable some forms of hijacking

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 5 21:58:15 UTC 2017


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

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m

--- Comment #2 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
How is that hijacking? When you use UFCS, you're saying that it should call the
member function with that name, and if there is no member function, then it
tries to call a matching free function. Anything else would make it impossible
to use a member function and a free function for the same functionality, and if
you reversed it so that it used UFCS instead, that would make it so that you
couldn't call the member function.

It was my understanding that UFCS was purposefully designed this way, and I
don't see how doing anything else makes sense. If you want to guarantee that
you're calling a free function rather than a member function, then just don't
use UFCS.

--


More information about the Digitalmars-d-bugs mailing list