Test case: ----------------------- int delegate(int a) bar6958(int x) { int y = x; int delegate (int a) xxx = (int a){ return a + y; }; return xxx; } int foo6958() { auto z = bar6958(4); assert(z(3) == 7); return 3; } static assert(foo6958());
This is still valid. Tested on DMD 2.080.0: closure.d(5): Error: closures are not yet supported in CTFE closure.d(10): called from here: bar6958(4) closure.d(15): called from here: foo6958() closure.d(15): while evaluating: static assert(foo6958()) I think it should be an enhancement rather than a bug though.
Adding another testcase, because the error message is different from the original testcase: ``` void func(int x, ref int delegate() dg) { int inner() { return x; } dg = &inner; } int check() { int delegate() dg; func(5, dg); return dg(); } pragma(msg, check()); ``` With DMD 2.094.2: <source>(3): Error: variable `x` cannot be read at compile time <source>(10): called from here: `dg()` <source>(12): called from here: `check()` <source>(12): while evaluating `pragma(msg, check())`
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18381 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB