[Issue 2608] New: int[] literal too polysemous

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 23 14:22:45 PST 2009


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: bugzilla at digitalmars.com
        ReportedBy: andrei at 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.


-- 



More information about the Digitalmars-d-bugs mailing list