Skip to content

Commit

Permalink
Merge pull request #8428 from ibuclaw/reg12378
Browse files Browse the repository at this point in the history
Fix Issue 19024 - [ICE] AssertError@dmd/dsymbolsem.d(4317): Assertion failure
  • Loading branch information
wilzbach committed Jul 2, 2018
2 parents ddddc2e + 484c9db commit 36f2383
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/dmd/dsymbolsem.d
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
19 changes: 19 additions & 0 deletions test/compilable/ice14739.d
@@ -0,0 +1,19 @@
// REQUIRED_ARGS: -o-

void main(string[] args)
{
immutable int a;
immutable int b;
S!a sa;
S!b sb;
C!a ca;
C!b cb;
}

struct S(alias a)
{
}

class C(alias a)
{
}
20 changes: 19 additions & 1 deletion test/fail_compilation/fail17492.d
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 36f2383

Please sign in to comment.