Submitted <b><a href="http://d.puremagic.com/issues/show_bug.cgi?id=4883"><b>Issue 4883</b></a><br><br><br></b><br><div class="gmail_quote">On Fri, Sep 17, 2010 at 4:30 PM, Steven Schveighoffer <span dir="ltr">&lt;<a href="mailto:schveiguy@yahoo.com">schveiguy@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Fri, 17 Sep 2010 17:15:31 -0400, Seth Hoenig &lt;<a href="mailto:seth.a.hoenig@gmail.com" target="_blank">seth.a.hoenig@gmail.com</a>&gt; wrote:<br>

<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have these two minimal programs:<br>
<br>
<br>
import std.string;<br>
void main()<br>
{<br>
    string str = &quot;abc&quot;;<br>
    int i = str.count(&quot;ab&quot;);<br>
<br>
}<br>
<br>
<br>
<br>
and:<br>
<br>
<br>
<br>
import std.string;<br>
import std.algorithm;<br>
void main()<br>
{<br>
    string str = &quot;abc&quot;;<br>
    int i = str.count(&quot;ab&quot;);<br>
<br>
}<br>
<br>
<br>
<br>
The only difference is line 2, where I import std.algorithm.<br>
The first program compiles fine, but the second program does not compile,<br>
spitting out the error message:<br>
<br>
bash-3.2$ dmd -ofdummy dummy.d<br>
/u/sah2659/dmd2/linux/bin/../../src/phobos/std/functional.d(176): Error:<br>
static assert  &quot;Bad binary function q{a == b}. You need to use a valid D<br>
expression using symbols a of type dchar and b of type string.&quot;<br>
/u/sah2659/dmd2/linux/bin/../../src/phobos/std/functional.d(179):<br>
instantiated from here: Body!(dchar,string)<br>
/u/sah2659/dmd2/linux/bin/../../src/phobos/std/algorithm.d(3410):<br>
instantiated from here: result!(dchar,string)<br>
dummy.d(7):        instantiated from here: count!(&quot;a == b&quot;,string,string)<br>
<br>
<br>
I can&#39;t imagine I&#39;m the first person to notice a bug like this, so is there<br>
something I am doing wrong?<br>
</blockquote>
<br></div></div>
I see two bugs here.  First, this should be an ambiguity error, because count matches both std.algorithm.count and std.string.count.  The compiler should refuse to compile this I think.<br>
<br>
Second, std.algorithm.count looks like this:<br>
<br>
size_t count(alias pred = &quot;a == b&quot;, Range, E)(Range r, E value) if (isInputRange!(Range))<br>
<br>
So, E can be any type, completely unrelated to strings, I could do:<br>
<br>
count!(string, int[]) which makes no sense.<br>
<br>
I think the sig should be<br>
<br>
size_t count(alias pred = &quot;a == b&quot;, Range, E)(Range r, E value) if (isInputRange!(Range) &amp;&amp; isImplicitlyConvertable!(E, ElementType!(Range)))<br>
<br>
-Steve<br>
</blockquote></div><br>