Bug 16082 – Can't access alias this member with same name as module

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-27T13:27:41Z
Last change time
2018-11-05T15:36:56Z
Assigned to
No Owner
Creator
Johan Engelen

Comments

Comment #0 by jbc.engelen — 2016-05-27T13:27:41Z
The following code does not compile ```D module modulename; struct S { struct Inner { int any_name_but_modulename; int modulename; } Inner inner; alias inner this; auto works() { return any_name_but_modulename; } auto fails() { return modulename; // Line 20 } } ``` and fails with: bug.d(20): Error: modulename is not an expression The problem is that S.Inner.modulename has the same name as the module. Tested with DMD 2.067, DMD2.070.2, and DMD2.071.0. They all fail.
Comment #1 by razvan.nitu1305 — 2018-10-25T14:00:41Z
Comment #2 by razvan.nitu1305 — 2018-10-29T12:02:36Z
Comment #3 by github-bugzilla — 2018-11-05T15:36:52Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/80ec7d9497ce93cfaba32def6636abbfff4f4a73 Fix Issue 16082 and 16086 https://github.com/dlang/dmd/commit/3d4fe18b61db85cab68535f17ee3cd249536a852 Merge pull request #8885 from RazvanN7/Alternate_16082 Fix Issues 16082 and 16086