From 573d877ff8408e724bd3627a36a4d7513e37d5d7 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Mon, 3 Jul 2017 15:52:07 -0700 Subject: [PATCH] fix Issue 17492 - [REG 2.066] [ICE] AssertError@ddmd/dclass.d(1007): Assertion failure --- src/ddmd/dclass.d | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ddmd/dclass.d b/src/ddmd/dclass.d index b89f85e15b97..e1023c7d041d 100644 --- a/src/ddmd/dclass.d +++ b/src/ddmd/dclass.d @@ -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. @@ -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); }