[Issue 13845] Error using alias of typeof(null) as unnamed lambda parameter
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Dec 15 07:47:02 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13845
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Peter Alexander from comment #1)
> alias Null = typeof(null);
> auto a = (int) => 0; // ok
> auto b = (typeof(null)) => 0; // ok
`int` and `typeof(null)` are definitely parsed as types.
> auto c = (Null x) => 0; // ok
`Null x` is parsed as a parameter, typed Null and parameter name is `x`.
> auto d = (Null) => 0; // error
>
> Error: variable bug.d type void is inferred from initializer (Null) => 0,
> and variables cannot be of type void
If a lambda parameter is an identifier, it's treated as the "parameter name".
Therefore it is equivalent with:
auto d = (x) => 0;
and compiler cannot infer the lambda parameter type so there's no "target"
type.
--
More information about the Digitalmars-d-bugs
mailing list