[Issue 24255] New: Can't deduce parameter type of function literal used as argument in IFTI
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 22 19:35:06 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24255
Issue ID: 24255
Summary: Can't deduce parameter type of function literal used
as argument in IFTI
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: snarwin+bugzilla at gmail.com
As of DMD 2.105.3, the following program fails to compile:
---
void fun(T)(T t, void function(T) f) {}
void main()
{
fun(123, (x) {});
}
---
The error message is:
---
bug.d(5): Error: template `bug.fun` is not callable using argument types
`!()(int, void)`
bug.d(1): Candidate is: `fun(T)(T t, void function(T) f)`
---
Since the compiler can deduce that T is int from the argument 123, it should be
able to further deduce that the argument (x) {} has type void function(int).
--
More information about the Digitalmars-d-bugs
mailing list