[Issue 2268] Hijacking of non-templated functions by templated functions should not be allowed.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 25 20:11:23 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2268


dsimcha at yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |critical
           Keywords|                            |diagnostic
            Version|2.017                       |2.023




------- Comment #2 from dsimcha at yahoo.com  2009-01-25 22:11 -------
Upgrading to critical and incrementing version because this bug still exists,
I've been bitten by this several times now, and each time it's quite confusing.
 Also, the following example actually does give a proper error message, because
instantiation of std.algorithm.find succeeds, and then DMD realizes that it
conflicts with std.string.find:

import std.algorithm, std.string;

void main() {
    auto i = find("foobar", 'f');
}


The root of the problem, then, is that DMD tries to instantiate any template
functions that match the name of the function being called before outputting a
name conflict error message.  If the instantiation of these templates fails,
then DMD fails with error messages related to its attempt at instantiating the
template, rather than either silently using the non-template function (probably
a bad idea) or failing with a name conflict error message (the right thing). 
Instead, DMD should fail *before* trying to instantiate the template function
whose name conflicts with the non-template function, if they are not in the
same overload set.


-- 



More information about the Digitalmars-d-bugs mailing list