[Issue 2410] New: array's invariant storage class dropped by a template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 9 08:36:58 PDT 2008


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

           Summary: array's invariant storage class dropped by a template
           Product: D
           Version: 2.014
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: marcin.wcislo at gmail.com


This snippet compiles correctly:

class Class {
    void foo(int[2] arg) {}
    void foo(invariant(int[2]) arg) {}
}

int main() {
    (new Class).foo([1, 1]);
    return 0;
}

(foo call is linked to foo(int[2]))

But this not:

class Class(T, int n) {
        void foo(T[n] arg) {}
        void foo(invariant(T[n]) arg) {}
}

int main() {
        (new Class!(int, 2)).foo([1, 1]);
        return 0;
}

error:
template.d(x): function template.Class!(int,2).Class.foo called with argument
types:
        (int[2u])
matches both:
        template.Class!(int,2).Class.foo(int[2u])
and:
        template.Class!(int,2).Class.foo(int[2u])


-- 



More information about the Digitalmars-d-bugs mailing list