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