Skip to content

Commit

Permalink
Merge pull request #3546 from 9rnsr/fix11333
Browse files Browse the repository at this point in the history
Issue 11333 - ICE: Cannot subtype 0-tuple with "alias this"
  • Loading branch information
WalterBright committed May 13, 2014
2 parents cf92eed + d629aa1 commit 9e82313
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/expression.c
Expand Up @@ -10910,12 +10910,15 @@ Expression *AssignExp::semantic(Scope *sc)
//printf("e = (%s %s, %s), ", Token::tochars[e->op], e->toChars(), e->type->toChars());
//printf("arg = (%s, %s)\n", arg->toChars(), arg->type->toChars());

if (!e->type->implicitConvTo(arg->type))
if (!arg || !e->type->implicitConvTo(arg->type))
{
// expand initializer to tuple
if (expandAliasThisTuples(iexps, u) != -1)
{
if (iexps->dim <= u)
break;
goto Lexpand;

}
goto Lnomatch;
}
}
Expand Down
27 changes: 27 additions & 0 deletions test/runnable/aliasthis.d
Expand Up @@ -1586,6 +1586,32 @@ void test11261()
}
}

/***************************************************/
// 11333

alias id11333(a...) = a;

struct Unit11333
{
enum value = Unit11333.init.tupleof;
alias value this;
}

void test11333()
{
void foo() {}

id11333!() unit;
unit = unit; // ok
foo(unit); // ok

unit = Unit11333.value; // ok
foo(Unit11333.value); // ok

Unit11333 unit2;
unit = unit2; // ok <- segfault
}

/***************************************************/
// 11800

Expand Down Expand Up @@ -1725,6 +1751,7 @@ int main()
test10004();
test10180();
test10456();
test11333();
test11800();

printf("Success\n");
Expand Down

0 comments on commit 9e82313

Please sign in to comment.