Spell checking errors can be hilarious

Steven Schveighoffer schveiguy at gmail.com
Wed Oct 14 15:32:07 UTC 2020


On 10/14/20 12:05 AM, Walter Bright wrote:
> On 10/13/2020 7:16 PM, Steven Schveighoffer wrote:
>> void main()
>> {
>>      auto x = to!string(1);
>> }
>>
>> Error: template instance to!string template to is not defined
>>
>> BUT you do this instead:
>>
>>      auto x = 1.to!string;
>>
>> And you get:
>>
>> Error: no property to for type int, perhaps import std.conv; is needed?
>>
>> Clearly, something is not triggering, it should be the same suggestion 
>> for both cases. (FWIW, if this bug wasn't present, the gentlemen 
>> trying out D in the stream would have immediately imported std.conv 
>> and have been done)
> 
> A case can always be concocted to show this either way. The two 
> expressions are equivalent, but they place different emphasis. I.e. the 
> first places emphasis on to being a function, the second places emphasis 
> on to being a property.

You might be missing the fact that when I call a function as a function, 
and not a method, it doesn't suggest any imports.

This problem doesn't happen with writeln:

void main()
{
     writeln("hello, world");
}

Error: writeln is not defined, perhaps import std.stdio; is needed?

I expect the compiler to suggest an import of std.conv when I use `to` 
in the *same way*.

> There isn't winning with this.

I don't have any idea what you mean. You mean, the feature to suggest 
imports is useless? There's no way to fix it?

Here's a full bug report: https://issues.dlang.org/show_bug.cgi?id=21308

-Steve


More information about the Digitalmars-d mailing list