www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5202] New: opIndexAssign doesn't work on structs obtained via getters

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5202

           Summary: opIndexAssign doesn't work on structs obtained via
                    getters
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com





-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 11 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5202


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid



Argh, accidentally hit enter.  Please disregard the blank first post.

struct OpIndexAssign {
    void opIndexAssign(uint val, uint index) {}
    uint opIndex(uint index) { return 42; }
}

struct Struct {
    OpIndexAssign oas;

    OpIndexAssign getter()  property {
        return oas;
    }
}

void main() {
    Struct s;
    s.oas[5] = 5;  // Works
    s.getter[5] = 5;  // Fails
}


Error message:

test.d(17): Error: s.getter()[5u] is not an lvalue

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 11 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5202


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com



Is this supposed to work?

It seems to me that this would require property rewriting, which is not
supported.

What would you expect this to do if the compiler did accept it, considering
that getter() does not return by ref?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 13 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5202


Nicolas Sicard <dransic free.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dransic free.fr



s.getter()[5] = 5;  // Works

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 13 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5202


Nils <mailme+d nilsb.dyndns.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |mailme+d nilsb.dyndns.org
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 4993 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 06 2012