[Issue 4816] template constraint and __traits(compiles, ...) don't work properly together with a delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 10 15:16:35 PST 2010


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


Nicolas Sicard <dransic at free.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dransic at free.fr


--- Comment #1 from Nicolas Sicard <dransic at free.fr> 2010-12-10 15:14:50 PST ---
This code won't compile (D v2.050) either. I think it is the same bug.

import std.stdio;

string process(alias callback)(string s)
    if (is(typeof(callback(s))))
{
    return s;
}

void main()
{
    void fun(string s) { write(s); }
    writeln(process!fun("Hello world!")); // OK

    enum dlg1 = (string s) { write(s); };
    writeln(process!dlg1("Hello world!")); // OK

    auto dlg2 = (string s) { write(s); };
    writeln(process!dlg2("Hello world!")); // ERROR
}

Error message:
test.d(18): Error: template instance process!(dlg2) does not match template
declaration process(alias callback) if (is(typeof(callback(s))))

-- 
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