[Issue 19144] Imported package have different protection depending on how it's accessed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 28 13:10:33 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19144

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
The matter of fact is that `__traits(getMember, file1, "std")` sees file1.std
as a package, while getProtection sees file1.std as an import.
`__traits(isSame)` compares them equally because [1] made it smart enough to
compare them.

The situation is a bit complicated because you cannot identify imports by their
first package. Consider this example:

//file1.d
public import std.stdio;
private import std.traits;

//file2.d
pragma(msg, __traits(getProtection, file1.std));

The invocation in file2 is ambiguous in this situation. However, if
getProtection would consider file.std as a package and not an import it would
pretty much become useless because the module itself is always public. I think
that we need to come up with a way of identifying imports. 

[1] https://github.com/dlang/dmd/pull/7095/files

--


More information about the Digitalmars-d-bugs mailing list