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 19024 - [ICE] AssertError@dmd/dsymbolsem.d(4317): Assertion failure #8428

Merged
merged 2 commits into from
Jul 2, 2018
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/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
19 changes: 19 additions & 0 deletions test/compilable/ice14739.d
Original file line number Diff line number Diff line change
@@ -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
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
{
}
}
}