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

           Summary: Function alias forward reference error
           Product: D
           Version: unspecified
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-05-03 04:33:47 PDT ---
This compiles and runs with no errors with dmd 2.044:


int fun(TElem)(TElem[] arr) { return 10; }
alias fun!(char) alternative; // LINE A
int alternative(int[] arr) { return 20; } // LINE B
void caller(TOp)(TOp op, char[] s) {
    assert(op(s) == 10);
}
void main() {
    caller(&alternative, cast(char[])"abc");
}



But if I swap the line A and B:


int fun(TElem)(TElem[] arr) { return 10; }
int alternative(int[] arr) { return 20; } // LINE B
alias fun!(char) alternative; // LINE A
void caller(TOp)(TOp op, char[] s) {
    assert(op(s) == 10);
}
void main() {
    caller(&alternative, cast(char[])"abc");
}


Then dmd 2.044 shows:
test.d(5): Error: cannot implicitly convert expression (s) of type char[] to
int[]
test.d(8): Error: template instance test.caller!(int function(int[] arr)) error
instantiating

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

Reply via email to