Thread overview | ||||||
---|---|---|---|---|---|---|
|
December 06, 2015 Are selective imports supposed to always be public? | ||||
---|---|---|---|---|
| ||||
Why does this code compile? Shouldn't the `isIntegral` import be private to module `testB` unless I explicitly ask for it to be public? // testB.d module testB; import std.traits : isIntegral; // testA.d module testA; void main(string[] args) { import testB; static assert(isIntegral!int); } |
December 06, 2015 Re: Are selective imports supposed to always be public? | ||||
---|---|---|---|---|
| ||||
Posted in reply to tsbockman | On Sunday, 6 December 2015 at 10:31:58 UTC, tsbockman wrote: > Why does this code compile? Shouldn't the `isIntegral` import be private to module `testB` unless I explicitly ask for it to be public? > > // testB.d > module testB; > > import std.traits : isIntegral; > > // testA.d > module testA; > > void main(string[] args) { > import testB; > static assert(isIntegral!int); > } A very old bug. https://issues.dlang.org/show_bug.cgi?id=314 |
December 06, 2015 Re: Are selective imports supposed to always be public? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Sunday, 6 December 2015 at 11:10:44 UTC, Mike Parker wrote: > A very old bug. > > https://issues.dlang.org/show_bug.cgi?id=314 Wow! 2006. Looks like it might get fixed soon, though: https://github.com/D-Programming-Language/dmd/pull/3407 |
December 06, 2015 Re: Are selective imports supposed to always be public? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Sunday, December 06, 2015 11:10:44 Mike Parker via Digitalmars-d-learn wrote:
> On Sunday, 6 December 2015 at 10:31:58 UTC, tsbockman wrote:
> > Why does this code compile? Shouldn't the `isIntegral` import be private to module `testB` unless I explicitly ask for it to be public?
> >
> > // testB.d
> > module testB;
> >
> > import std.traits : isIntegral;
> >
> > // testA.d
> > module testA;
> >
> > void main(string[] args) {
> > import testB;
> > static assert(isIntegral!int);
> > }
>
> A very old bug.
>
> https://issues.dlang.org/show_bug.cgi?id=314
Yeah. At this point, you should basically never use selective imports at the module-level.
As I understand it, work has been done towards fixing this bug and some related bugs recently, but the compiler devs aren't in agreement on the changes. So, for the moment at least, the bug continues to be a problem, but there's a good chance that it'll get fixed semi-soon.
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation