[Issue 20110] Module constructor implicitly converts a delegate pointer into a function pointer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 6 06:17:07 UTC 2019


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

--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
Ah I botched up the code sample, great.

This is the one:

-----
import std.stdio;

alias void function(int, int) Callback;

void passCallback ( Callback cb )
{
    cb(10, 20);
}

class C
{
    static this()
    {
        passCallback(&test);  // doesn't fail????
    }

    void test (int foo, int bar)
    {
        writefln("foo: %s, bar: %s", foo, bar);
    }
}

void main ()
{
    auto c = new C;
    static assert(!is(typeof(passCallback(&c.test))));  // correct
}
-----

--


More information about the Digitalmars-d-bugs mailing list