Bug 8653 – cannot take address of auto-return function declared in outside module: "Error: forward reference"
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-13T17:56:00Z
Last change time
2012-09-15T06:42:01Z
Assigned to
nobody
Creator
thelastmammoth
Comments
Comment #0 by thelastmammoth — 2012-09-13T17:56:27Z
See the following code for CT error.
It seems we cannot take address of auto-return function declared in outside module, but we can if it's declared in the same module.
The CT error is: "Error: forward reference"
file main.d:
----
import fun;
void run3(Fun,T...)(Fun fun,T args){
fun(args);
}
class A1{
void fun1(double x){
}
double fun2(double x){
return x;
}
auto fun3(double x){
return x;
}
auto fun4(double x){
}
}
void main(){
test1;
test2;
}
void test1(){
auto a=new A1;
run3(&a.fun1,1);
run3(&a.fun2,1);
run3(&a.fun3,1);
run3(&a.fun4,1);
}
void test2(){
auto a=new A2;
run3(&a.fun1,1);
run3(&a.fun2,1);
run3(&a.fun3,1);//CT error
run3(&a.fun4,1);//CT error
}
-----
file fun.d:
----
module fun;
class A2{
void fun1(double x){
}
double fun2(double x){
return x;
}
auto fun3(double x){
return x;
}
auto fun4(double x){
}
}
----
Comment #1 by k.hara.pg — 2012-09-15T06:42:01Z
This is a dup of bug 5933.
I've already posted a pull request for that, but not yet merged.
*** This issue has been marked as a duplicate of issue 5933 ***