Bug 15150 – [REG2.068.1] Public selective import causes conflict
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-04T03:21:00Z
Last change time
2017-08-02T08:07:37Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2015-10-04T03:21:53Z
//// a.d ////
enum { x }
//// b.d ////
import a : x;
//// c.d ////
import a;
import b;
enum y = x;
/////////////
c.d(4): Error: a.x at a.d(1) conflicts with a.x at b.d(1)
Introduced in https://github.com/D-Programming-Language/dmd/pull/4918
Comment #1 by k.hara.pg — 2015-10-04T16:19:02Z
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.