conflicting alias in package module

Steven Schveighoffer schveiguy at gmail.com
Sat Sep 26 15:12:47 UTC 2020


On 9/26/20 10:59 AM, 60rntogo wrote:
> On Saturday, 26 September 2020 at 13:45:21 UTC, Steven Schveighoffer wrote:
>> A selective import is equivalent to aliasing (to the public) the 
>> symbol as if it were defined in that scope.
>>
>> You have to label it as private if you want it to be private.
> 
> Are you saying that I should write this in bar.d?
> 
> private import pack : Foo;
> 
> This still gives the same error.
> 

Oh wait, I missed the problem. It's here:


pack/bar.d:
module pack.bar;

import pack : Foo;

Here you are importing the PACKAGE, which is importing bar, which is 
trying to define Foo. It's a recursive loop.

Instead:

import pack.foo : Foo;

Works.

-Steve


More information about the Digitalmars-d-learn mailing list