[Issue 15925] -transition=[check]imports ignores import declaration from mixin templates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 22 20:18:28 PDT 2016


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

--- Comment #22 from Mathias Lang <mathias.lang at sociomantic.com> ---
> I think what you are saying is that a mixed in template could affect existing *imports*, right? But an import can already do that! Ignoring imports with mixins doesn't fix this problem.

An import can already hijack an import if it appears at scope lexically
'closer' to the looked-up symbol, but yes, imports can still hijack.
I don't know if there is any solution to that issue, short of allowing only one
level of import, which of course is out of question.

> The mixin could not hijack local symbols, right? I thought that was the larger point -- you are referring to class/local symbols, or even module functions, and suddenly that changes through a hijacked import.

It could be implemented both ways, since those are two different lists of
imports. I believe the sane way to do it (and the approach I used IIRC) would
be to look up mixed in / inherited imports after local ones.

> I get that it's good to prevent hijacking as much as possible. But this doesn't disallow hijacking to any further degree than is already disallowed. In other words, preventing mixins from hijacking imported symbols doesn't remove the problem, and just makes the language inconsistent.

It disallows some imports, so it *does* prevent hijacking by definition.
Whether or not those hijackings are a common enough source of bugs, and the
feature it disallows is useful, is up to one's judgment.

As for inconsistency, I disagree. With the separated lookup, there is no way to
inherit an 'import scope'. This means any hijacking can only ever come from an
import that is in your module. I believe that was the important property Walter
was after: https://issues.dlang.org/show_bug.cgi?id=15966#c3

Note that as the original author of this issue (and the similar #15966) I'm
only the messenger, and not the one that took the decision.
IOW, I'm fighting someone else's war here, and he's the one you have to
convince if you want this overturned :-)

--


More information about the Digitalmars-d-bugs mailing list