This used to compile (probably dmd 2.060):

struct Foo {
    immutable int y;
    void bar(TF)(TF f) pure {
        f(1);
    }
    void spam() pure {
        bar((int x) => y);
    }
}
void main() {}


But now it gives:

test.d(4): Error: pure function 'test.Foo.bar!(immutable(int) delegate(int x) nothrow @safe).bar' cannot call impure delegate 'f' test.d(7): Error: template instance test.Foo.bar!(immutable(int) delegate(int x) nothrow @safe) error instantiating

Is it a correct error?

Bye,
bearophile

Reply via email to