[Issue 12402] New: Improved typing for array concatenation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 18 05:14:15 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12402

           Summary: Improved typing for array concatenation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2014-03-18 05:14:14 PDT ---
int[5] foo(int[2] a, int[3] b) {
    typeof(return) result = a ~ b; // OK
    return result;
}
int[5] bar(int[2] a, int[3] b) {
    return a ~ b;                  // Error
}
void main() {}


DMD 2.066alpha gives:

test2.d(6,12): Error: cannot implicitly convert expression (cast(int[])a ~
cast(int[])b) of type int[] to int[5]


I suggest to support the code in bar() too. (A small optimization can even
remove any heap allocations from the bar() function).

I am not sure, but perhaps the solution is similar to a value range
propagation: to propagate the statically known length of an array. (Expecially
for immutable arrays, as in Issue 10594 ).

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


More information about the Digitalmars-d-bugs mailing list