[Issue 6958] [CTFE] closures are not yet supported in CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 17 22:34:39 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=6958

--- Comment #2 from johanengelen at weka.io ---
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())`

--


More information about the Digitalmars-d-bugs mailing list