[Solved] Confusing error message
drug via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 7 12:02:59 PDT 2017
07.06.2017 21:07, bachmeier пишет:
> On Wednesday, 7 June 2017 at 14:58:26 UTC, drug wrote:
>
>> For me it's a good message.
>
> Messages like this were an annoyance when I started out. If you don't
> import std.stdio, you get the error message
>
> Error: 'writeln' is not defined, perhaps you need to import std.stdio; ?
>
> That's a very helpful error message if you're new to D, and especially
> helpful if you're new to programming. This particular error is likely a
> common one, and adding "perhaps you need to import std.conv" would help
> a lot. Even a generic "perhaps you forgot an import statement" would
> tell new users what the error might be. Making it worse is that it says
> core.time.to but there was no import of core.time.
How do compiler know that you want use `std.conv.to` instead of _already
imported_ `core.time.to`? In general it's impossible. There is no way
for compiler to guess that you want some other symbol from out there.
What if you've imported `std.conv.to` but want to use `core.time.to` -
what should compiler do in this case?
What about `writeln` - it's too different.
More information about the Digitalmars-d-learn
mailing list