digitalmars.D.learn - One case of GC-allocated closure
- bearophile (21/21) May 26 2014 I don't know if this is a bug, an enhancement request, or just a
I don't know if this is a bug, an enhancement request, or just a
mistake of mine. I don't understand why currently nogc refuses
this code:
import std.algorithm: filter;
struct Foo {
bool bar(in int) nogc {
return true;
}
auto spam() nogc {
immutable static data = [1, 2];
//return data.filter!bar; // Not allowed?
return data.filter!(i => bar(i)); // Error
}
}
void main() {}
dmd 2.066alpha gives:
test.d(6,10): Error: function test1.Foo.spam nogc function
allocates a closure with the GC
Is this a bug/ER worth reporting?
Bye,
bearophile
May 26 2014








"bearophile" <bearophileHUGS lycos.com>