[Issue 7265] Function Literals where a keyword was omitted should be delegate even if inference.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 16 09:25:17 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7265


Andrei Alexandrescu <andrei at metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei at metalanguage.com


--- Comment #4 from Andrei Alexandrescu <andrei at metalanguage.com> 2012-01-16 09:25:15 PST ---
(In reply to comment #3)
> Everything behaves as specified in TDPL. This is not a compiler bug.

Yah, I just tested this:

import std.stdio, std.traits;
void main()
{
    auto fn = { writeln("function"); };
    static assert(isFunctionPointer!(typeof(fn)));
    int x;
    auto dg = { writeln("delegate because it prints ", x); };
    static assert(isDelegate!(typeof(dg)));
}

So the literal is properly classified as a function or delegate depending on it
needing a frame pointer or not.

There's one remaining question I have. I rewrote the example like this:


import std.stdio, std.traits;

void main()
{
    auto fn = { writeln("function"); };
    static assert(is(typeof(fn) == function));

    int x;
    auto dg = { writeln("delegate because it prints ", x); };
    static assert(is(typeof(dg) == delegate));
}

The second static assert works, but the first doesn't. Why?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list