[Issue 24255] Can't deduce parameter type of function literal used as argument in IFTI

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 2 14:33:46 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24255

Paul Backus <snarwin+bugzilla at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #3 from Paul Backus <snarwin+bugzilla at 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.

--


More information about the Digitalmars-d-bugs mailing list