diff --git a/src/mars.c b/src/mars.c index 359ca30febfd..99ba788d17c9 100644 --- a/src/mars.c +++ b/src/mars.c @@ -1563,6 +1563,15 @@ Language changes listed by -transition=id:\n\ Module::dprogress = 1; Module::runDeferredSemantic(); + if (Module::deferred.dim) + { + for (size_t i = 0; i < Module::deferred.dim; i++) + { + Dsymbol *sd = Module::deferred[i]; + sd->error("unable to resolve forward reference in definition"); + } + fatal(); + } // Do pass 2 semantic analysis for (size_t i = 0; i < modules.dim; i++) diff --git a/src/module.c b/src/module.c index 1c623d968354..c240e6ce9021 100644 --- a/src/module.c +++ b/src/module.c @@ -758,16 +758,6 @@ void Module::semantic() void Module::semantic2() { - if (deferred.dim) - { - for (size_t i = 0; i < deferred.dim; i++) - { - Dsymbol *sd = deferred[i]; - - sd->error("unable to resolve forward reference in definition"); - } - return; - } //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); if (semanticRun != PASSsemanticdone) // semantic() not completed yet - could be recursive call return; diff --git a/test/compilable/test12009.d b/test/compilable/test12009.d new file mode 100644 index 000000000000..be6049bf7571 --- /dev/null +++ b/test/compilable/test12009.d @@ -0,0 +1,36 @@ +struct RefCounted(T) +{ + struct RefCountedStore + { + private struct Impl + { + T _payload; + } + + private Impl* _store; + } + RefCountedStore _refCounted; + + ~this() + { + import core.stdc.stdlib : free; + } +} + +struct GroupBy(R) +{ + struct SharedInput + { + Group unused; + } + + struct Group + { + private RefCounted!SharedInput _allGroups; + } +} + +void main() +{ + GroupBy!(int[]) g1; +}