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

           Summary: [CTFE] struct member array.length -= x doesn't work,
                    while array[0..$-x] works
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: dmitry.o...@gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.o...@gmail.com> 2011-07-29 
07:05:49 PDT ---
It has something to do with structs, test case:

struct A{
    int[] arr;
    int subLen()
    {    
        arr = [1,2,3, 4,5];
        arr.length -= 1; //replace this line with a next and it compiles
//        arr = arr[0..$-1]; 
        return arr.length;
    }
}


int getMeFour()
{
    A a;
    return a.subLen();    
}

int getMeFour2()
{    
    auto arr = [1,2,3, 4,5];
    arr.length -= 1;
    return arr.length;
}

enum t1 = getMeFour();
enum t2 = getMeFour2();//this works regardless of -=x or [0..$-x]
static assert(t1 == 4);
static assert(t2 == 4);

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

Reply via email to