diff --git a/compiler/src/dmd/semantic3.d b/compiler/src/dmd/semantic3.d index d89413f43fef..cd25ac012d78 100644 --- a/compiler/src/dmd/semantic3.d +++ b/compiler/src/dmd/semantic3.d @@ -1612,6 +1612,10 @@ private extern(C++) final class Semantic3Visitor : Visitor override void visit(TypeInfoAssociativeArrayDeclaration ti) { + if (ti.semanticRun >= PASS.semantic3) + return; + ti.semanticRun = PASS.semantic3; + auto t = ti.tinfo.isTypeAArray(); Loc loc = t.loc; auto sc2 = sc ? sc : ti._scope; @@ -1643,19 +1647,24 @@ private extern(C++) final class Semantic3Visitor : Visitor // generate ti.xtoHash auto hashinst = makeDotExp(Identifier.idPool("aaGetHash")); e = expressionSemantic(hashinst, sc2); - assert(e.isVarExp() && e.type.isTypeFunction()); - ti.xtoHash = e.isVarExp().var; - if (auto tmpl = ti.xtoHash.parent.isTemplateInstance()) - tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + if (!e.isErrorExp()) + { + assert(e.isVarExp() && e.type.isTypeFunction()); + ti.xtoHash = e.isVarExp().var; + if (auto tmpl = ti.xtoHash.parent.isTemplateInstance()) + tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + } // generate ti.xopEqual auto equalinst = makeDotExp(Identifier.idPool("aaOpEqual")); e = expressionSemantic(equalinst, sc2); - assert(e.isVarExp() && e.type.isTypeFunction()); - ti.xopEqual = e.isVarExp().var; - if (auto tmpl = ti.xopEqual.parent.isTemplateInstance()) - tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted - + if (!e.isErrorExp()) + { + assert(e.isVarExp() && e.type.isTypeFunction()); + ti.xopEqual = e.isVarExp().var; + if (auto tmpl = ti.xopEqual.parent.isTemplateInstance()) + tmpl.minst = sc2._module.importedFrom; // ensure it gets emitted + } visit(cast(ASTCodegen.TypeInfoDeclaration)ti); } } diff --git a/compiler/test/fail_compilation/test20863.d b/compiler/test/fail_compilation/test20863.d new file mode 100644 index 000000000000..2808da50e381 --- /dev/null +++ b/compiler/test/fail_compilation/test20863.d @@ -0,0 +1,23 @@ +// must not assert/crash with empty declarations +/* TEST_OUTPUT: +--- +fail_compilation\test20863.d(21): Error: no property `Entry` for type `object.TypeInfo_AssociativeArray` +fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here +fail_compilation\test20863.d(21): Error: no property `aaGetHash` for type `object.TypeInfo_AssociativeArray` +fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here +fail_compilation\test20863.d(21): Error: no property `aaOpEqual` for type `object.TypeInfo_AssociativeArray` +fail_compilation\test20863.d(17): class `TypeInfo_AssociativeArray` defined here +--- +*/ + +module object; + +class Object { } +class TypeInfo { } +class TypeInfo_AssociativeArray { } + +extern(C) int main() +{ + int[int] aa; + return 0; +}