Bug 8131 – Delegate type inference with templates is absolutely *horrible*

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-21T23:37:25Z
Last change time
2024-12-13T18:00:02Z
Keywords
diagnostic, rejects-valid
Assigned to
No Owner
Creator
dlang+issues
See also
https://issues.dlang.org/show_bug.cgi?id=22501
Moved to GitHub: dmd#18441 →

Comments

Comment #0 by dlang+issues — 2012-05-21T23:37:25Z
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 by dlang+issues — 2012-05-21T23:40:53Z
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 by hsteoh — 2014-06-30T18:15:55Z
Still happens on git HEAD (db18e36a1c060fff056ecfa88cf792edc8ef8c1d).
Comment #3 by hsteoh — 2019-02-06T22:53:20Z
Still happens on git HEAD (v2.084.0-395-gcb3a72613).
Comment #4 by robert.schadek — 2024-12-13T18:00:02Z
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