https://issues.dlang.org/show_bug.cgi?id=15925
--- Comment #18 from Mathias Lang <[email protected]> --- (In reply to Steven Schveighoffer from comment #17) > (In reply to Mathias Lang from comment #16) > > The details of the bug were wrong (it should be ignored unlike what I > > originally believed) > > While this has your attention, can you point me at the rationale to why this > is so? See my earlier comment 14. Sorry, I forgot to reply to c14. The rationale is that this behavior allowed symbol hijacking. The behavior of the compiler was changed to perform 2 passes for symbol resolution, the first one on local symbol, the second one on imports. E.g. the infamous: ``` static immutable text = "Hello world"; void main () { import std.conv; writeln(text); } ``` Used to print nothing because the imported 'std.conv.text' symbol used to take priority. This proved to be a frequent source of confusion for developers. See https://issues.dlang.org/show_bug.cgi?id=10378 for the actual issue. Now there is something special about 'mixin template' and 'class' / 'interface' declaration: they are the only remote (as in, outside of the module) symbol one can inherit it's scope from. But inheriting the imports leads to the same issues 10378 describe: you can end up in a situation where adding a symbol to module 'foo' which is 'protected import' of class 'A' will suddenly change which symbol is selected in subclass 'B : A'. However, if you have both imports at the same level, you'll get a conflict. The only kind of hijacking I can think of ATM is when an import which is more nested than another one introduce an already-used symbol. E.g. if this class used 'b.myFunc' before and a new library introduce 'd.myFunc': ``` import b; class Foo { import d; pragma(msg, typeof(myFunc)); } ``` Hope that was clear enough. Feel free to reach out to me by email if not. > BTW, we shouldn't rename or repurpose bugs like this. I generally agree. In this case, the P.R. was already merged and appeared in the changelog. It created confusion ( https://forum.dlang.org/post/[email protected] ), so I took the pragmatic road and just fixed stuff. --
