[Issue 13451] Lambda syntax with explicit return type not documented

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Sep 18 17:26:10 PDT 2014


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

--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to briancschott from comment #0)
> ---
> fp = function int(int a) => a;
> ---

When I cleaned up parser code for lambdas, the syntax was intentional as that
is a combination of:
  - the keyword "function" for function literals
  - optional return type specification
  - parameter list
  - lambda style function literal body ("=>" with one AssignExpression)

So, I'd fix the grammar to fit accepted code by dmd, like follows.

Lambda:
    function Type(opt) ParameterAttributes => AssignExpression
    delegate Type(opt) ParameterAttributes => AssignExpression
    ParameterAttributes => AssignExpression
    Identifier => AssignExpression

--


More information about the Digitalmars-d-bugs mailing list