No property error message

JR via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 19 12:02:40 PDT 2016


On Saturday, 19 March 2016 at 18:36:10 UTC, ric maicle wrote:
> I got an error message with the following code saying:
>
>   Error: no property 'length' for type 'int[string]'
>
> Shouldn't the error message say 'length()'?
>
> ~~~
> import std.stdio;
>
> void main() {
>   int[string] a;
>   a["one"] = 1;
>   a["two"] = 2;
>   a["three"] = 3;
>   auto len = a.length();
> }
> ~~~
>
> DMD 2.070.2

Well, if we think of it as separate steps, resolving the function 
"length" is what's failing here. The subsequent () would just 
call it, if it existed, but the name of the property/symbol would 
still be "length".

But yes; you could make a case that, in the case of invalid 
function calls, it should include the whole erroneous attempted 
function signature in the error message. I can imagine it 
becoming ambiguous once templates enter the picture however, and 
for not much gain.


More information about the Digitalmars-d-learn mailing list