D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2696 - Spurious "if"clause of template function shown in error message
Summary: Spurious "if"clause of template function shown in error message
Status: RESOLVED DUPLICATE of issue 7768
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: Walter Bright
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2009-02-28 14:51 UTC by Andrei Alexandrescu
Modified: 2014-02-14 20:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2009-02-28 14:51:43 UTC
(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).
Comment 1 Walter Bright 2009-03-14 20:27:20 UTC
The "if" clause is printed because it is part of the template declaration, not its definition.
Comment 2 Kenji Hara 2012-03-25 01:16:57 UTC

*** This issue has been marked as a duplicate of issue 7768 ***