Skip to content

Commit

Permalink
fix Issue 12009 - local import and "unable to resolve forward referen…
Browse files Browse the repository at this point in the history
…ce" error

`Module::semantic2` could be invoked from local imports, even when some
local symbol semantics are not yet completed.
  • Loading branch information
9rnsr committed Apr 3, 2014
1 parent f92062c commit 9681667
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/mars.c
Expand Up @@ -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++)
Expand Down
10 changes: 0 additions & 10 deletions src/module.c
Expand Up @@ -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;
Expand Down
36 changes: 36 additions & 0 deletions 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;
}

0 comments on commit 9681667

Please sign in to comment.