On Sun, 13 Feb 2011 09:33:40 -0500, d coder <dlang.co...@gmail.com> wrote:
Greetings
I am getting this error when I am instantiating a struct array with a
single element inside another class and only if there is the
destructor for the struct is explicitly defined. Is it a known error?
Here is a minimized snippet that gives error:
$ rdmd --main -unittest test.d
Error: this for ~this needs to be type foo not type foo[1u][1u]
Error: this for ~this needs to be type foo not type foo[1u]
// test.d
struct foo {
int foofoo;
~this() { // no error if explicit destructor not
// defined
}
}
class bar {
foo fred;
foo[2][2] foofoo;
foo[1] frop; // this gives error
foo[1][1] fropfrop; // this too
}
unittest {
foo frop;
foo[1][1] fropfrop; // this works
bar burp;
}
I think it is a bug. The compiler appears to be "optimizing" out the
array, since you are creating a static array of exactly one element, it's
the same as just creating an element.
But it somehow forgets that it optimized that out.
Please file on bugzilla.
-Steve