www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16082] New: Can't access alias this member with same name as


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

The following code does not compile
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.

May 27 2016