Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1818 from 9rnsr/fix9759
[REG2.063a] Issue 9759 - compiler segfault in StructLiteral::implicitConvTo(Type*) on invalid code
  • Loading branch information
WalterBright committed Mar 31, 2013
2 parents 8b9d88d + 174c895 commit 89d3caf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cast.c
Expand Up @@ -452,7 +452,10 @@ MATCH StructLiteralExp::implicitConvTo(Type *t)
{
m = MATCHconst;
for (size_t i = 0; i < elements->dim; i++)
{ Expression *e = (*elements)[i];
{
Expression *e = (*elements)[i];
if (!e)
continue;
Type *te = e->type;
te = te->castMod(t->mod);
MATCH m2 = e->implicitConvTo(te);
Expand Down
25 changes: 25 additions & 0 deletions test/fail_compilation/ice9759.d
@@ -0,0 +1,25 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice9759.d(24): Error: mutable method ice9759.Json.opAssign is not callable using a const object
---
*/

struct Json
{
union
{
Json[] m_array;
Json[string] m_object;
}

void opAssign(Json v)
{
}
}

void bug()
{
const(Json) r;
r = r.init;
}

0 comments on commit 89d3caf

Please sign in to comment.