http://d.puremagic.com/issues/show_bug.cgi?id=2608

           Summary: int[] literal too polysemous
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzi...@digitalmars.com
        ReportedBy: and...@metalanguage.com


The following code fails:

void next(T)(ref T[] a) { assert(a.length); a = a[1 .. $]; }

void main()
{
    auto a = [ 1, 2, 3 ];
    a.next;
    assert(a == [ 2, 3 ]);
}

If one replaces "auto" with "int[]", the code compiles and runs as expected. It
looks like auto with literals tries too hard to keep it around as an rvalue.

This seems to be related to issue 2606.


-- 

Reply via email to