Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing a second module enables FQN sidestepping selective import #19622

Open
dlangBugzillaToGithub opened this issue Sep 19, 2019 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

Simen Kjaeraas reported this on 2019-09-19T07:38:52Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=20229

Description

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant