Re: No property error message

2016-03-21 Thread Steven Schveighoffer via Digitalmars-d-learn

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


Re: No property error message

2016-03-19 Thread JR via Digitalmars-d-learn

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.


No property error message

2016-03-19 Thread ric maicle via Digitalmars-d-learn

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