D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8131 - Delegate type inference with templates is absolutely *horrible*
Summary: Delegate type inference with templates is absolutely *horrible*
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-05-21 23:37 UTC by dlang+issues
Modified: 2024-12-13 18:00 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 dlang+issues 2012-05-21 23:37:25 UTC
The code:

	import std.range;
	void f(R)(R, void delegate(ElementType!R)) { }
	void main() { f([1], (int x) { }); }

gives:

	Error: template f does not match any function template declaration
	Error: template f(R) cannot deduce template function from argument types !()(int[],void function(int x) pure nothrow @safe)


but it should obviously be able to infer the types...
Comment 1 dlang+issues 2012-05-21 23:40:53 UTC
Also another issue, likely to be related:


The code

	import std.range;
	void f(R)(R, void delegate(ElementType!(R))) { }
	void main() { f([1], delegate void(x) { }); }

says

	Error: undefined identifier R, did you mean template f(R)?
	Error: ElementType!(_error_) is used as a type
	Error: template f does not match any function template declaration
	Error: template f(R) cannot deduce template function from argument types !()(int[],void)

even though 'R' and 'ElementType' are clearly both defined.
Comment 2 hsteoh 2014-06-30 18:15:55 UTC
Still happens on git HEAD (db18e36a1c060fff056ecfa88cf792edc8ef8c1d).
Comment 3 hsteoh 2019-02-06 22:53:20 UTC
Still happens on git HEAD (v2.084.0-395-gcb3a72613).
Comment 4 dlangBugzillaToGithub 2024-12-13 18:00:02 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18441

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB