Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 17492 - [REG 2.066] [ICE] AssertError@ddmd/dclass.d(1007): … #6964

Merged
merged 1 commit into from
Jul 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe split this into an error an errorSupplemental?

error("already exists, perhaps in another function with the same name.");
errorSupplemental(cd.loc, "previous declaration found here.");

Rather than formating the location into the error string.

}

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
{
}
}
}