Yes, it can be surprising, but I'm not convinced it's actually wrong
behavior (the bug is http://d.puremagic.com/issues/show_bug.cgi?id=2043)
Just do this:
size_t c = count!(function(x, e) { return x.e == e;} )(source, e);
and it will work. [1]
artur
[1] I don't do that new kinky lambda syntax, sorry. ;)

You have found a bug in DMD.
Reduced test case that should compile:
template Seq(T...){alias T Seq;}
auto exec(alias a)(){return a();}
void main(){
foreach(e; Seq!(0, 1))
static assert(exec!(()=>e)()==e);
}
You can report the bug here: http://d.puremagic.com/issues/
The 'exec' template is instantiated only once instead of two times.