On Mon, 15 Dec 2014 22:09:28 +0000
CraigDillabaugh via Digitalmars-d-learn
<digitalmars-d-learn@puremagic.com> wrote:

> Given the following program:
> 
> import std.string;
> import std.stdio;
> 
> void main()
> {     
>       File file = File("blah.txt", "r");
>       
>       while( !(file.eof()) && count > 10 ) {  //line 8
>               //
>       }
> }
> 
> I get the error message:
> 
> line(8): Error: void has no value
> 
> If I comment out the import std.string; then I get an error I 
> would expect.
> 
> line(8): Error: undefined identifier count
> 
> There is no 'count' symbol that I can see in std.string.
there is public import from std.algorithm inside std.string, so what
you see is about std.algorithm.count.

> Would this error message be considered a compiler bug?
i don't think so. compiler tries to instantiate std.algorithm.count and
failed doing that, so it tries to tell you about that failure. newer
compiler will tell you this:

z00.d(8): Error: void has no value
z00.d(8): Error: incompatible types for ((count(alias pred = "a == b", Range, 
E)(Range haystack, E needle)
  if (isInputRange!Range && !isInfinite!Range &&
  is(typeof(binaryFun!pred(haystack.front, needle)) : bool))) > (10)): 'void' 
and 'int'

this is slightly better, albeit still cryptic. template instantiation
error messages are of the most noisy and hard to understand ones. alas.
but poor compiler at least tries to help you. ;-)

Attachment: signature.asc
Description: PGP signature

Reply via email to