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.
Comment #2 by k.hara.pg — 2015-10-05T01:55:38Z
Comment #3 by github-bugzilla — 2015-10-06T06:53:32Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9e1e61d6e9d7713f8d64def9c468c0771bb6efff fix Issue 15150 - Public selective import causes conflict By making `EnumMember` to the subclass of `VarDeclaration`, the symbol itself can be representation of the enum member name. https://github.com/D-Programming-Language/dmd/commit/f8d24cd1796bfe369fcd55feff191b99b96aa094 Merge pull request #5161 from 9rnsr/fix15150 [REG2.068.1] Issue 15150 - Public selective import causes conflict
Comment #4 by github-bugzilla — 2015-10-07T02:56:30Z
Comment #5 by github-bugzilla — 2017-08-02T08:07:37Z
Commit pushed to dmd-cxx at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/72e863ea02676f4eab27e3df6af6aa98ec99f57b Issue 15150 - Public selective import causes conflict