diff --git a/src/dmd/dsymbolsem.d b/src/dmd/dsymbolsem.d index 2acb48a88f3f..ed2b7b321276 100644 --- a/src/dmd/dsymbolsem.d +++ b/src/dmd/dsymbolsem.d @@ -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. @@ -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) diff --git a/test/compilable/ice14739.d b/test/compilable/ice14739.d new file mode 100644 index 000000000000..cc90da6342e8 --- /dev/null +++ b/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) +{ +} diff --git a/test/fail_compilation/fail17492.d b/test/fail_compilation/fail17492.d index ac59f49eb7b3..dca6f6fc0888 100644 --- a/test/fail_compilation/fail17492.d +++ b/test/fail_compilation/fail17492.d @@ -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 */ @@ -25,3 +26,20 @@ class C } } } + +class S +{ + void testE() + { + struct I + { + } + } + + void testE() + { + struct I + { + } + } +}