November 22, 2023 [Issue 24255] New: Can't deduce parameter type of function literal used as argument in IFTI | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: snarwin+bugzilla@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). -- |
Copyright © 1999-2021 by the D Language Foundation