digitalmars.D.learn - No property error message
- ric maicle (14/14) Mar 19 2016 I got an error message with the following code saying:
- JR (10/24) Mar 19 2016 Well, if we think of it as separate steps, resolving the function
- Steven Schveighoffer (16/19) Mar 21 2016 No, it should say length is a property, not a function. a.length should
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
Mar 19 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.2Well, 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.
Mar 19 2016
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
Mar 21 2016