D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20229 - Importing a second module enables FQN sidestepping selective import
Summary: Importing a second module enables FQN sidestepping selective import
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-19 07:38 UTC by Simen Kjaeraas
Modified: 2024-12-13 19:05 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Simen Kjaeraas 2019-09-19 07:38:52 UTC
unittest {
    import std.complex : complex;
    static assert(!__traits(compiles, { alias a = std.complex.abs; }));
}
unittest {
    import std.complex : complex;
    import std.internal.test.uda; // module with no imports
    static assert(__traits(compiles, { alias a = std.complex.abs; }));
}

In the first block above, we can't refer to std.complex.abs, as it's not imported by the selective import statement. In the second block however, the presence of a second, non-selective, import statement makes std.complex.abs accessible again.

Note that the module selected has no imports, and it's thus not a case of referring to imports in that imported module.

Note also that the name of the second module is important - it needs to be in the same package as the first imported module. I tested with a module called `bar`, and the static assert correctly triggered, but renaming the module to std.bar (still an empty file) made it compile again.
Comment 1 dlangBugzillaToGithub 2024-12-13 19:05:39 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19622

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB