Skip to content

Conversation

@WalterBright
Copy link
Member

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To compile test11039.d and imports/test11039b.d separately, you need to add // COMPILE_SEPARATELY option here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@9rnsr
Copy link
Contributor

9rnsr commented Sep 19, 2013

OK, looks good.

9rnsr added a commit that referenced this pull request Sep 19, 2013
fix Issue 11039 - Undefined instantiation from circular imports
@9rnsr 9rnsr merged commit 9ff2c36 into dlang:master Sep 19, 2013
@MartinNowak
Copy link
Member

If mi imports any root modules, we still need to generate the code.

What's the logic behind this?

@WalterBright WalterBright deleted the fix11039 branch September 19, 2013 06:26
@WalterBright
Copy link
Member Author

It happens when a non-root module circularly imports a root one. Somebody has to instantiate it.

@9rnsr
Copy link
Contributor

9rnsr commented Sep 19, 2013

And, in the test code, SomeStruct!string is instantiated in both module, then merged on link-time.

@MartinNowak
Copy link
Member

It happens when a non-root module circularly imports a root one. Somebody has to instantiate it.

I see, when you later compile the non-root module the roles inverted so both would delegate the instantiation to some other module.
You could try to improve this fix in two ways.

  • Restrict the "imports any root" module search to those root modules that also instantiate the template.
  • Use a fixed method to determine the module of a circular import chain that is responsible for the instantiation, e.g. take the module with the lexically smallest module name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants