www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12648] New: Array operation return type

https://issues.dlang.org/show_bug.cgi?id=12648

          Issue ID: 12648
           Summary: Array operation return type
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

I think both the following should compile:


int[1] foo1(int[1] a) {
    a[] += 10;
    return a;         // OK.
}
int[1] foo2(int[1] a) {
    return a[] += 10; // Error.
}
void main() {}


DMD 2.066alpha gives:

test.d(6,16): Error: cannot implicitly convert expression
(_arrayExpSliceAddass_i(a[], 10)) of type int[] to int[1]

--
Apr 25 2014