www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12876] New: Implicit cast of array slice to fixed-size array

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

          Issue ID: 12876
           Summary: Implicit cast of array slice to fixed-size array for
                    templates too
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

I am not sure this is a valid enhancement request. This code could be accepted:


void foo(int[4] b) {}
void bar(size_t N)(int[N] c) {}
void main() {
    int[5] a;
    foo(a[1 .. $]); // OK
    bar(a[1 .. $]); // Error.
}


DMD 2.066alpha gives:

test.d(6,8): Error: template test.bar cannot deduce function from argument
types !()(int[]), candidates are:
test.d(2,6):        test.bar(uint N)(int[N] c)

--
Jun 08 2014