This is simplified code which I am using in my project.


```
struct NumberType
{
    int num;

    int opApply(int delegate(int) dg)
    {
        int result = dg(num);
        return result;
    }
}

struct Problem {
    int value;

    this(int val) {
        auto myType = NumberType(18);

        foreach (int number; myType)
        {
            return;
        }
    }
}

auto compile_time_var = Problem(1);

void TestFunction() {
    auto runtime_var = Problem(1);
}
```

I am creating instance of Problem struct in runtime and compile time. Following call is giving me compilation time.

```
auto compile_time_var = Problem(1);
```

Following is the error:
```
Error: variable `__capture` cannot be read at compile time
```

Is there a restriction that I cannot call **return** from foreach (opApply delegate) if it is executed at compile time?

Reply via email to