Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 02 [Issue 24255] Can't deduce parameter type of function literal used as argument in IFTI | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24255 basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |b2.temp@gmx.com --- Comment #1 from basile-z <b2.temp@gmx.com> --- Took me a while to get that but I think that in `void function(T)` it's not the same `T` as in `void fun(T)` -- |
September 02 [Issue 24255] Can't deduce parameter type of function literal used as argument in IFTI | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24255 --- Comment #2 from basile-z <b2.temp@gmx.com> --- to be more clear ``` void fun(T)(T t, void function(T) f) {} void argOK(int){} void argNG(OtherT)(OtherT ot){} void main() { fun(123, &argOK); fun(123, &argNG); // semantically equivalent to the original test case } ``` -- |
September 02 [Issue 24255] Can't deduce parameter type of function literal used as argument in IFTI | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24255 Paul Backus <snarwin+bugzilla@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement --- Comment #3 from Paul Backus <snarwin+bugzilla@gmail.com> --- Yes, in the current implementation of the DMD frontend, the compiler performs semantic analysis on the argument `(x) {}` *before* it attempts to deduce the template argument `T`, and as a result, it determines that `(x) {}` is template lambda. However, there is nothing in the language spec that requires the DMD frontend to behave this way. In your example, argNG can *only* be a template, because it is explicitly declared as one. But in the original example, the lambda expression `(x) {}` is ambiguous: it could be a template, or it could be a `void function(int)`. Given that the language spec gives the compiler the freedom to interpret `(x) {}` either way, I think it's reasonable to request that the compiler choose the more useful interpretation. Of course, by the same logic, we can't say that the current behavior is *wrong*, so I'll change this to an enhancement request. -- |
September 02 [Issue 24255] Can't deduce parameter type of function literal used as argument in IFTI | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24255 --- Comment #4 from basile-z <b2.temp@gmx.com> --- I agree over the fact that this is an enhancement request. -- |
Copyright © 1999-2021 by the D Language Foundation