I guess these are CTFE (compile-time function evaluation) issues,
someone else might know more. A workaround is to use a module
constructor which will run before main():

struct Test {
   int delegate(int) f;
}

Test s;

static this() {
    s = Test((int x) { return x + 1; });
}

Note that 's' is thread-local, to make it shared across threads but
without implicit synchronization you can use:

__gshared Test s;

shared static this() {
    s = Test((int x) { return x + 1; });
}

Note the use of *shared* in the module ctor. Without 'shared' it would
run every time a new thread was spawned.

Reply via email to