[Issue 15179] Local imports cause outer imports to be excluded from overload set

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Mar 31 06:37:11 PDT 2016


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

Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|regression                  |enhancement

--- Comment #9 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Jesse Phillips from comment #8)
> It does not. Since I wrote code where selective imports was not necessary,
> an update to a second library being used hijacked my call and the compiler
> gave no warning. That is the hijack problem, the fact that I can modify my
> code to use the desired function is not relevant to how the compiler is
> supposed to help prevent hijacking: http://dlang.org/hijack.html

Of course selective imports aren't necessary. But importing locally without
using selective imports is prone to this issue.

I would argue any time you do a scoped import of a module you don't control,
you should use static, renamed, or selective imports. This narrows the focus of
what you are looking for, and is not subject to overriding or hijacking since
it's treated as a local alias.

D can do some things to prevent hijacking, but you must remember that it
doesn't have a history of code. It cannot always deduce that something was
hijacked and that's not what you intended.

Note, I just realized this isn't a regression, it's an enhancement. The import
rules are working as they were designed. If we are to change anything, it would
be a new design.

--


More information about the Digitalmars-d-bugs mailing list