[Issue 15150] [REG2.068.1] Public selective import causes conflict

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Oct 4 09:19:02 PDT 2015


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

--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> ---
The direct cause is the change TypeIdentifier.toDsymbol in PR 4918, but the
root cause is more deep.

When a symbol identifier is looked up via Dsymbol.search, an EnumMember symbol
can be returned.

On the other hand, a TypeIdentifier resolution by using Type.resolve always
returns a wrapper VarExp for the EnumMember symbol.

It means that, currently a EnumMember object can be represented by two ways. In
the provided test case:

//// c.d ////

import a;
import b;

enum y = x;
 // 1. from module a, ScopeDsymbol.search returns EnumMember('a.x')
 // 2. from module b, ScopeDsymbol.search returns AliasDeclaration('b.x'), and
 //   it's _import field is not null.
 // 2a. In the AliasDeclaration.semantic, its type is TypeIdentifier('x').
 //     Before the PR 4918 change, type.toDsymbol(sc) at line 598 had returned
 //     EnumMember symbol, but after that, the AliasDeclaration is changed to
refer
 //     the wrapper VarDeclaration instead.
 // 3. Then, scopeDsymbol.search will try to create OverloadSet for the
 //    identifier 'x' search, because the imports give two different symbols
 //    (EnuMmember and its wrapper VarDeclaration). But of course it fails, and
 //    the "Error a.x at a.d(1) conflicts with a.x at b.d(1)" is reported.

The wrapper VarDeclaration is introduce in the PR to support UDAs for enum
members.

https://github.com/D-Programming-Language/dmd/pull/1960

To fix the "two face of EnumMember" issue, I think EnumMember class should be
derived from VarDeclaration.

--


More information about the Digitalmars-d-bugs mailing list