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


--- Comment #0 from David Simcha <dsimcha yahoo.com> 2010-11-11 12:05:54 PST ---


-- 
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


--- Comment #1 from David Simcha <dsimcha yahoo.com> 2010-11-11 12:07:32 PST ---
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


--- Comment #2 from yebblies <yebblies gmail.com> 2010-11-13 03:13:46 PST ---
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


--- Comment #3 from Nicolas Sicard <dransic free.fr> 2011-01-13 23:48:17 PST ---
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


--- Comment #4 from Nils <mailme+d nilsb.dyndns.org> 2012-03-06 23:34:22 PST ---
*** 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