Identifier resolution, the great implementation defined mess.

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 21 16:50:43 PDT 2014


On 09/22/2014 01:37 AM, deadalnix wrote:
> On Sunday, 21 September 2014 at 20:05:57 UTC, Walter Bright wrote:
>> On 9/20/2014 10:29 PM, deadalnix wrote:
>>> DMD does very bizarre things. I think I should write a DIP, but time
>>> is always
>>> running low...
>>>
>>> Free goodie: when you import, all symbol are resolved via the
>>> expected import
>>> resolution mechanism. All ? No, the root package is imported in the
>>> local scope.
>>>
>>> foo(int a) {
>>>   import a.b.c;
>>>   // a is now a package and not the parameter a anymore.
>>> }
>>
>> What's bizarre about it? You declared a package symbol 'a' in the
>> local scope with the import declaration.
>>
>
> Because this is not consistent with module level import

Yes it is.

> and that is not consistent with how local shadowing works.

Indeed.

>
> IMO you should fallback to import if local lookup failed.

The package symbol is not imported, it is introduced by imports. This is 
true in module scopes and local scopes alike.


More information about the Digitalmars-d mailing list