[Issue 10378] Local imports hide local symbols

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 19 15:38:19 PDT 2015


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

timon.gehr at gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr at gmx.ch

--- Comment #12 from timon.gehr at gmx.ch ---
(In reply to deadalnix from comment #9)
> Proposal:
> 
> Free symbol are resolved from the inner scope to the outer scope WITHOUT
> considering imports. If that lookup fails, the symbol is searched in import
> from the inner scope to the outer scope.
> 
> A variant is to aggregate import into the inner scope.
> 
> This solution has various advantages:
>  - import cannot hijack in module symbols implicitly.
>  - import do not need to be processed if local lookup succeed, and doing
> less work is always a way to make the compiler faster.
> 
> The main difference between the first proposal and the variant is that that
> in the first proposal, an inner imported module's symbol can hijack an outer
> imported one. In the variant, it doesn't happen, but the import lookup phase
> will be much heavier, as the compiler must look into all imported module at
> once.

Another solution would be to not have an a priori precedence order for symbols
that are imported and symbols that are found in an enclosing scope, and to then
do the usual overload resolution. (Think of this like treating enclosing scopes
as imports.) This is more in line with the anti-hijacking design philosophy of
the module system.

--


More information about the Digitalmars-d-bugs mailing list