digitalmars.D.bugs - [Issue 4152] New: Function alias forward reference error
- d-bugmail puremagic.com (42/42) May 03 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4152
- d-bugmail puremagic.com (9/9) Aug 22 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4152
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 puremagic.com
ReportedBy: bearophile_hugs eml.cc
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: -------
May 03 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4152
Another case, maybe with a different cause:
struct Foo(alias f) {}
Foo!main baz;
void main() {}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 22 2010








d-bugmail puremagic.com