Error: @nogc function 'test.func2' cannot call non- at nogc delegate 'msg'
Shachar Shemesh
shachar at weka.io
Sun Dec 10 12:00:28 UTC 2017
On 10/12/17 13:44, Jonathan M Davis wrote:
> it sounds like the delegate that's
> being generated isn't @nogc, so it can't be called within the function,
> which would be a completely different issue from allocating a closure.
Here's the thing, though. There is no reason for the delegate to be
called at all!
Since func1's msg is also lazy, I expected the lowering to look like this:
void func1(/*scope*/ string delegate() msg) @nogc {
}
void func2(/*scope*/ string delegate() msg) @nogc {
func1(msg);
}
Even with scope commented out, the above compiles just fine. The fact
that msg is not @nogc doesn't matter at all, simply because no one is
evaluating the delegate.
More information about the Digitalmars-d
mailing list