dmd
dmd copied to clipboard
Array comparison with recursive inferred opEquals gives confusing error message
The following code:
struct A {
A[] as;
auto opEquals(A x) {
return as == x.as;
}
}
void main() {
}
produces the compiler error:
Error: incompatible types for array comparison: `A[]` and `A[]`
Replacing auto with bool causes it to compile.
I guess one would expect an error of the form:
can't infer return type in function opEquals...
Note, if you don't use array comparisons but simply recurse, you get this:
struct A {
A[] as;
auto opEquals(A x) {
return x == this;
}
}
Error: forward reference to inferred return type of function call `x.opEquals(this)`
I would expect a similar error for the array form.