Skip to content

Commit

Permalink
fix Issue 17492 - [REG 2.066] [ICE] AssertError@ddmd/dclass.d(1007): …
Browse files Browse the repository at this point in the history
…Assertion failure
  • Loading branch information
WalterBright committed Jul 3, 2017
1 parent ea2033f commit b9e92f3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/ddmd/dclass.d
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,18 @@ extern (C++) class ClassDeclaration : AggregateDeclaration

sc2.pop();

if (type.ty == Tclass && (cast(TypeClass)type).sym != this)
{
// https://issues.dlang.org/show_bug.cgi?id=17492
ClassDeclaration cd = (cast(TypeClass)type).sym;
version (none)
{
printf("this = %p %s\n", this, this.toPrettyChars());
printf("type = %d sym = %p, %s\n", type.ty, cd, cd.toPrettyChars());
}
error("already exists at %s. Perhaps in another function with the same name?", cd.loc.toChars());
}

if (global.errors != errors)
{
// The type is no good.
Expand Down Expand Up @@ -995,16 +1007,6 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
deferred.semantic2(sc);
deferred.semantic3(sc);
}

version (none)
{
if (type.ty == Tclass && (cast(TypeClass)type).sym != this)
{
printf("this = %p %s\n", this, this.toChars());
printf("type = %d sym = %p\n", type.ty, (cast(TypeClass)type).sym);
}
}
assert(type.ty != Tclass || (cast(TypeClass)type).sym == this);
//printf("-ClassDeclaration.semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this);
}

Expand Down
23 changes: 23 additions & 0 deletions test/fail_compilation/fail17492.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* TEST_OUTPUT:
---
fail_compilation/fail17492.d(19): Error: class fail17492.C.testE.I already exists at fail_compilation/fail17492.d(12). Perhaps in another function with the same name?
---
https://issues.dlang.org/show_bug.cgi?id=17492
*/

class C
{
void testE()
{
class I
{
}
}

void testE()
{
class I
{
}
}
}

0 comments on commit b9e92f3

Please sign in to comment.