www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8064] New: return reference semantics not obeyed on delegates?

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

           Summary: return reference semantics not obeyed on delegates?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: gasper.azman gmail.com



PDT ---
I feel this is best explained with a testcase:
This is the error DMD gives:
test.d(21): Error: arryacc(3LU) is not an lvalue


class A {
   private size_t size = 5;
   auto newArrayAccessor(T)() {
      T[] a = new T[size];
      ref T accessor(size_t i) {
          return a[i];
      }
      return &accessor;
   }
}

void main() {
   uint[5] arry;
   ref uint acc(size_t i) {
       return arry[i];
   }
   acc(3) = 5; // works

   auto a = new A;
   auto arryacc = a.newArrayAccessor!(uint)();
   arryacc(3) = 5; // doesn't work. What gives?
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8064




PDT ---
Simplified testcase (by q66):
void main() {
   uint[5] arry;
   ref uint acc(size_t i) {
       return arry[i];
   }
   auto arryacc = &acc;
   arryacc(3) = 5; // same error
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8064


Kenji Hara <k.hara.pg gmail.com> changed:

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



https://github.com/D-Programming-Language/dmd/pull/933

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8064




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/5a9b927ae2501aac795c03d1cd6be79188e1e197
fix Issue 8064 - return reference semantics not obeyed on delegates?

https://github.com/D-Programming-Language/dmd/commit/813a0216b2a205fb06bd8d02d7c667317c7b5ce4


Issue 8064 - return reference semantics not obeyed on delegates?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 10 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8064


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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