Skip to content

Commit

Permalink
Fix Issue 19024 - [ICE] AssertError@dmd/dsymbolsem.d(4317): Assertion…
Browse files Browse the repository at this point in the history
… failure
  • Loading branch information
ibuclaw committed Jul 1, 2018
1 parent 3a54f9d commit 61383c3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4291,6 +4291,18 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
}
}

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

if (global.errors != errors)
{
// The type is no good.
Expand All @@ -4305,16 +4317,6 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
sd.deferred.semantic2(sc);
sd.deferred.semantic3(sc);
}

version (none)
{
if (sd.type.ty == Tstruct && (cast(TypeStruct)sd.type).sym != sd)
{
printf("this = %p %s\n", sd, sd.toChars());
printf("type = %d sym = %p\n", sd.type.ty, (cast(TypeStruct)sd.type).sym);
}
}
assert(sd.type.ty != Tstruct || (cast(TypeStruct)sd.type).sym == sd);
}

final void interfaceSemantic(ClassDeclaration cd)
Expand Down
20 changes: 19 additions & 1 deletion test/fail_compilation/fail17492.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Disabled for 2.079, s.t. a deprecation cycle can be started with 2.080
DISABLED: win32 win64 osx linux freebsd dragonflybsd
TEST_OUTPUT:
---
fail_compilation/fail17492.d(17): Error: function `fail17492.C.testE()` conflicts with previous declaration at fail_compilation/fail17492.d(10)
fail_compilation/fail17492.d(20): Error: class `fail17492.C.testE.I` already exists at fail17492.d(13). Perhaps in another function with the same name?
fail_compilation/fail17492.d(37): Error: struct `fail17492.S.testE.I` already exists at fail17492.d(30). Perhaps in another function with the same name?
---
https://issues.dlang.org/show_bug.cgi?id=17492
*/
Expand All @@ -25,3 +26,20 @@ class C
}
}
}

class S
{
void testE()
{
struct I
{
}
}

void testE()
{
struct I
{
}
}
}

0 comments on commit 61383c3

Please sign in to comment.