D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8654 - cannot take address of function which is 1)overloaded, 2) templated, and 3) member (static or not): Error: xxx is not an lvalue
Summary: cannot take address of function which is 1)overloaded, 2) templated, and 3) m...
Status: RESOLVED DUPLICATE of issue 1983
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2012-09-13 17:58 UTC by thelastmammoth
Modified: 2014-04-16 04:45 UTC (History)
2 users (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:58:46 UTC
here's my other weird example, which I managed to simplify to as follows. Basically if:
1) the function is overloaded, and
2) it is a template, and
3) it is a member function (either static or nonstatic)

Then you get  a CT error that looks like: Error: (A).fun!(2) is not an lvalue


That's a bug too right? (but different!)

I wish delegates were more 1st class citizens and behaved...

----
void run(Fun)(Fun fun){
}

class A {
	void fun1(int T)() if(T==2) {	}

	void fun2(int T)() if(T==1) {	}
	void fun2(int T)() if(T==2) {	}

	void fun3(){}
	void fun3(int x){}

	void fun4(int T)() if(T==1) {	}
	void fun4(int T)(int x) if(T==2) {	}

	void fun5(T)()  {	}
	void fun5(T)(int x)  {	}

	static void fun6(int T)() if(T==1) {	}
	static void fun6(int T)() if(T==2) {	}
}

void fun7(int T)() if(T==1) {	}
void fun7(int T)() if(T==2) {	}



void main(){
	auto a=new A;
	run(&a.fun1!2); //works
	//run(&a.fun2!2); //CT Error: a.fun2!(2) is not an lvalue
	run(&a.fun3); //works
	//run(&a.fun4!2); //CT Error: a.fun4!(2) is not an lvalue
	//run(&a.fun5!double); //CT Error: a.fun5!(double) is not an lvalue
	//run(&A.fun6!2); //CT Error: (A).fun6!(2) is not an lvalue
	run(&fun7!2); //works
}
----
Comment 1 yebblies 2013-11-24 08:03:18 UTC
All of these now work, except for run(&a.fun5!double); which ICEs after correctly being rejected.
Comment 2 Kenji Hara 2014-01-22 08:48:40 UTC
run(&a.fun3); should be ambiguous, because there's not enough context to determine overload resolution.
Comment 3 yebblies 2014-02-04 04:06:32 UTC
fun5 no longer ices, fun3's accepts-invalid is probably a duplicate.
Comment 4 Kenji Hara 2014-04-16 04:45:04 UTC
(In reply to Kenji Hara from comment #2)
> run(&a.fun3); should be ambiguous, because there's not enough context to
> determine overload resolution.

Current state with 2.066 git-head is:

void main()
{
    auto a=new A;
    run(&a.fun1!2);       // correctly accepted
    run(&a.fun2!2);       // correctly accepted
    run(&a.fun3);         // wrongly accepted -> dup of issue 1983
    run(&a.fun4!2);       // correctly accepted
  //run(&a.fun5!double);  // correctly rejected
    // Error "matches more than one template declaration", expected
    run(&A.fun6!2);       // correctly accepted
    run(&fun7!2);         // correctly accepted
}

*** This issue has been marked as a duplicate of issue 1983 ***