[Issue 4152] New: Function alias forward reference error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon May 3 04:33:48 PDT 2010
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: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at 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: -------
More information about the Digitalmars-d-bugs
mailing list