[Issue 8064] New: return reference semantics not obeyed on delegates?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 8 03:10:42 PDT 2012


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 at puremagic.com
        ReportedBy: gasper.azman at gmail.com


--- Comment #0 from Gašper Ažman <gasper.azman at gmail.com> 2012-05-08 03:12:02 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
code: #####

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


More information about the Digitalmars-d-bugs mailing list