[Issue 16082] New: Can't access alias this member with same name as module

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri May 27 06:27:41 PDT 2016


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

          Issue ID: 16082
           Summary: Can't access alias this member with same name as
                    module
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: jbc.engelen at gmail.com

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.

--


More information about the Digitalmars-d-bugs mailing list