www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - mixins, delegates...

This code:

////////////////////////////
void bar ( void delegate () dg ) { dg(); }

template MCaller ( alias f )
{
    void caller ( int i )
    {
        bar ( delegate { f(i); } );
    }
}

class A
{
    mixin MCaller!(foo);

    void foo (int i) {}
}

class B
{
    mixin MCaller!(baz);

    void baz (int i) {}
}
////////////////////////////

Produces this output when compiling:

test.d(5): function caller cannot access frame of function __anonymous
test.d(7): delegate __anonymous cannot access frame of function caller
test.d(7): delegate __anonymous cannot access frame of function caller

However, if I leave only one of either A or B, it compiles perfectly fine.
Tried with DMD 0.95 on WinXP Pro.

-----------------------
Carlos Santander Bernal
Jul 12 2004