[Issue 17156] Local function declaration not inferred to be static

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu May 11 17:52:43 PDT 2017


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

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla at digitalmars.com
         Resolution|---                         |INVALID

--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> ---
The trouble is this:

    uint g() { return 5; }
    ...
    uint delegate() d = &g;

Your proposal would cause that to fail. Inference is done for template 'a'
because the assignment is part of the expression. But for the 'g' case, there
may be intervening code of this sort:

    uint g() { return 5; }
    uint function() c = &g;
    uint delegate() d = &g;

'g' cannot be both a function and a delegate. So the simple rule is 'static'
being there or not sets it to be a function pointer or a delegate. This is
consistent with other uses of 'static'.

This is working as designed. Not a bug.

--


More information about the Digitalmars-d-bugs mailing list