Bug 6958 – [CTFE] closures are not yet supported in CTFE

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-11-16T05:33:59Z
Last change time
2024-12-13T17:56:56Z
Keywords
CTFE, industry
Assigned to
No Owner
Creator
Don
Moved to GitHub: dmd#18381 →

Comments

Comment #0 by clugdbug — 2011-11-16T05:33:59Z
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());
Comment #1 by lance — 2019-05-11T19:10:51Z
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.
Comment #2 by johanengelen — 2021-11-17T22:34:39Z
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())`
Comment #3 by robert.schadek — 2024-12-13T17:56:56Z
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