www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Current UFCS diagnostic problem

reply "bearophile" <bearophileHUGS lycos.com> writes:
Currently there is a significant problem with UFCS usage, visible 
in this wrong program:


import std.algorithm, std.array;

int[] foo(R)(R data) {
     return data.map!(x => y ^^ 2).array;
}

void main() {
     auto r1 = [1, 2, 3].foo;
}


The latest dmd 2.063alpha gives just the error:

test.d(8): Error: no property 'foo' for type 'int[]'


dmd keeps giving the same error for lot mutations of the code of 
foo(). When the code gets more complex, with some UFCS chains, 
debugging code becomes not easy. (This is already in Bugzilla). 
I'd like this problem to be somehow addressed before the release 
of dmd 2.063.

Bye,
bearophile
Mar 27 2013
parent Jacob Carlborg <doob me.com> writes:
On 2013-03-27 15:50, bearophile wrote:
 Currently there is a significant problem with UFCS usage, visible in
 this wrong program:


 import std.algorithm, std.array;

 int[] foo(R)(R data) {
      return data.map!(x => y ^^ 2).array;
 }

 void main() {
      auto r1 = [1, 2, 3].foo;
 }


 The latest dmd 2.063alpha gives just the error:

 test.d(8): Error: no property 'foo' for type 'int[]'


 dmd keeps giving the same error for lot mutations of the code of foo().
 When the code gets more complex, with some UFCS chains, debugging code
 becomes not easy. (This is already in Bugzilla). I'd like this problem
 to be somehow addressed before the release of dmd 2.063.
If think I've seen something similar. When there's an ambiguous function call it will give the same error as above instead of giving an error about ambiguity. -- /Jacob Carlborg
Mar 27 2013