Assertion failure during compilation with DMD v2.049:
$ cat test.d
struct S {
void delegate() d;
}
void main() {
shared S[] s;
s[0] = S();
}
$ dmd test
dmd: cast.c:432: virtual MATCH StructLiteralExp::implicitConvTo(Type*): Assertion `t->mod == 4' failed.
Aborted
Comment #1 by clugdbug — 2010-11-29T07:20:25Z
Applies to any struct which contains a non-trivial type: delegate, pointer, class, or dynamic array.
There are a few other cases where it applies, not just shared.
---
struct Bug5025 {
int[] d;
}
shared Bug5025 b5025 = Bug5025();
const shared Bug5025 b5025a = Bug5025();
inout(Bug5025) bug5025c(inout Bug5025 xxx)
{
return Bug5025();
}
-----------
PATCH
cast.c line 429.
-----------
m = MATCHconst;
for (int i = 0; i < elements->dim; i++)
{ Expression *e = (Expression *)elements->data[i];
Type *te = e->type;
- if (t->mod == 0)
- te = te->mutableOf();
- else
- { assert(t->mod == MODimmutable);
- te = te->invariantOf();
- }
+ te = te->castMod(t->mod);
MATCH m2 = e->implicitConvTo(te);
//printf("\t%s => %s, match = %d\n", e->toChars(), te->toChars(), m2);
if (m2 < m)