Since 2.071, protection attributes is a misnomer, since it now participates in symbol lookup.
`private` symbols won't conflict with same-named symbols in other modules for example, however the specs ( http://dlang.org/spec/attribute.html#ProtectionAttribute ) currently says otherwise. Hence this section is in need of a rename / overhaul.
For reference, two links where the new behaviour was discussed:
- DIP22 implementation: https://github.com/dlang/dmd/pull/5472
- Martin's comment in 15897: https://issues.dlang.org/show_bug.cgi?id=15897#c12
Name lookup is also not documented in the specs, and it might be worth making visibility and lookup rules be in their own, dedicated section.
Leaving aside the current bugs, name lookup is now performed in two phases:
- First local declarations / member of the scope
- Then imports of that scope
Scopes are considered in the following order:
A) Local
B) Mixin templates
C) Base class
D) Enclosing scope (starting from step A)
Note: For the import part, there is an issue opened: https://issues.dlang.org/show_bug.cgi?id=15966
The underlying reason for this order is to forbid any local symbol hijacking (imported symbol hijacking is still possible) if a module introduces a new symbol.