Comment #0 by timothee.cour2 — 2015-07-01T18:32:01Z
----
struct A{
auto opSlice(uint dim)(int a, int b){
foobar();
return 0;
}
auto opIndex(T...)(T args){
return 2;
}
}
void main(){
A a;
a[0..1, 0];//Error: multi-dimensional slicing requires template opSlice
//a[0..1];//slightly less cryptic error message for this
}
----
Comment #1 by timothee.cour2 — 2015-07-01T18:34:55Z
forgot to add:
of course the error is that 'foobar()' doesn't compile, but the error message provided completely hides that, and is confusing, since user did define opSlice.
I'm guessing implementation uses something such as __traits(compiles, expr) to check whether user defined the template and error gagging prevents showing it.
Either way, as it is, in larger programs, it can be very hard to figure out the reason of the bug given poor compiler msg
Comment #2 by robert.schadek — 2024-12-13T18:43:38Z