A purity change
bearophile
bearophileHUGS at lycos.com
Thu Jul 11 08:25:09 PDT 2013
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
More information about the Digitalmars-d-learn
mailing list