Spell checking errors can be hilarious

Jacob Carlborg doob at me.com
Tue Oct 13 08:31:34 UTC 2020


On Monday, 12 October 2020 at 20:46:07 UTC, Steven Schveighoffer 
wrote:

> What do you mean? Just add "to" : "std.conv". Is there a 
> problem with it?

It's already in the list [1], it's been there for two years. 
Unfortunately it's not that simple. The current implementation is 
a very simple mapping of a name to an import. What if there are 
multiple module level symbols with the same name in Phobos or 
druntime? Then the compiler will be wrong in some of those cases. 
Also, take this for example:

auto too(T, U)(U value)
{
     return value;
}

void main()
{
     auto a = 3.to!string;
}

This will result in a compile error:

Error: no property `to` for type `int`, perhaps `import 
std.conv;` is needed?

Obviously I meant to call the function `too` in the same module. 
Not `std.conv.to`.

[1] 
https://github.com/dlang/dmd/blob/aef4ac2a0901e4f2bf6cefe4c69a9c4c22cce76d/src/dmd/imphint.d#L78

--
/Jacob Carlborg


More information about the Digitalmars-d mailing list