Thread overview | |||||
---|---|---|---|---|---|
|
March 20, 2016 No property error message | ||||
---|---|---|---|---|
| ||||
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 |
March 19, 2016 Re: No property error message | ||||
---|---|---|---|---|
| ||||
Posted in reply to ric maicle | 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.
|
March 21, 2016 Re: No property error message | ||||
---|---|---|---|---|
| ||||
Posted in reply to ric maicle | On 3/19/16 2:36 PM, 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()'?
No, it should say length is a property, not a function. a.length should work.
Note the error message here:
struct S
{
int x;
}
void main()
{
S s;
s.x();
}
function expected before (), not s.x of type int
Please file a bug report.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation