Thread overview
[Issue 2696] New: Spurious "if"clause of template function shown in error message
Feb 28, 2009
d-bugmail
Mar 15, 2009
d-bugmail
Mar 25, 2012
Kenji Hara
February 28, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2696

           Summary: Spurious "if"clause of template function shown in error
                    message
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: andrei@metalanguage.com


(Thanks CLXX for submitting this to the newsgroup.)

void fun(T)(T t) if (is(T == string)) {}
void fun(T)(T t) if (is(T == int)) {}

void main( ){
    fun(1.0);
}

yields the errors:

./test.d(5): template test.fun(T) if (is(T == string)) does not match any
function template declaration
./test.d(5): template test.fun(T) if (is(T == string)) cannot deduce template
function from argument types !()(double)

The if (...) clause is superfluous as the compiler seems to print there whatever fun overload was first in the module. The correct error message is:

./test.d(5): template test.fun(T) does not match any function template
declaration
./test.d(5): template test.fun(T) cannot deduce template function from argument
type !()(double)

Notice the grammar fix too :o).


-- 

March 15, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2696





------- Comment #1 from bugzilla@digitalmars.com  2009-03-14 20:27 -------
The "if" clause is printed because it is part of the template declaration, not its definition.


-- 

March 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2696


Kenji Hara <k.hara.pg@gmail.com> changed:

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


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-25 01:16:57 PDT ---
*** This issue has been marked as a duplicate of issue 7768 ***

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