Thread overview
[Issue 2268] New: Compiler should generate function name conflict error with templated functions.
Aug 06, 2008
d-bugmail
[Issue 2268] Hijacking of non-templated functions by templated functions should not be allowed.
Sep 04, 2008
d-bugmail
Jan 26, 2009
d-bugmail
Jan 31, 2009
d-bugmail
May 13, 2009
David Simcha
August 06, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2268

           Summary: Compiler should generate function name conflict error
                    with templated functions.
           Product: D
           Version: 2.017
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: dsimcha@yahoo.com


It appears that the compiler does not properly handle collisions between function names in different modules when one of the functions is a template.

Case 1:  Find is not templated in either std.string or std.regexp, compilation fails with a conflicts error message.

import std.string, std.regexp;

void main() {
    int i = find("foobar", "foo");
}

Case 2:  Find is templated in std.algorithm, compiler silently tries to instantiate std.algorithm.find, instantiation fails with error specific to std.algorithm.find implementation.

import std.string, std.algorithm;

void main() {
    int i = find("foobar", "foo");
}

I've marked this bug as major because, if a user runs into it and is not aware of it, it can be extremely difficult to figure out why the program doesn't compile.


-- 

September 04, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2268


dsimcha@yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Compiler should generate    |Hijacking of non-templated
                   |function name conflict error|functions by templated
                   |with templated functions.   |functions should not be
                   |                            |allowed.




------- Comment #1 from dsimcha@yahoo.com  2008-09-04 14:56 -------
Added much more descriptive title, now that I'm more familiar with the general issue here.


-- 

January 26, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2268


dsimcha@yahoo.com changed:

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




------- Comment #2 from dsimcha@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.


-- 

January 31, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2268


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com
            Version|2.023                       |2.017




------- Comment #3 from smjg@iname.com  2009-01-30 20:44 -------
The rule around here is that the version field should be set to the _oldest_ version in which the bug has been observed.

http://tinyurl.com/avzytb


-- 

May 13, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2268


David Simcha <dsimcha@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #4 from David Simcha <dsimcha@yahoo.com>  2009-05-13 09:29:01 PDT ---
Works in 2.030, but see bug 2972.  I think the fix caused this bug.

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