D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8653 - cannot take address of auto-return function declared in outside module: "Error: forward reference"
Summary: cannot take address of auto-return function declared in outside module: "Erro...
Status: RESOLVED DUPLICATE of issue 5933
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-13 17:56 UTC by thelastmammoth
Modified: 2012-09-15 06:42 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description thelastmammoth 2012-09-13 17:56:27 UTC
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 Kenji Hara 2012-09-15 06:42:01 UTC
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 ***