Variables with scoped destruction in closures
Walter Bright via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Oct 14 22:41:05 PDT 2016
On 10/14/2016 3:18 AM, Nordlöw wrote:
> t_scope.d(23,6): Error: variable t_scope.below.s has scoped destruction, cannot
> build closure
https://github.com/dlang/dmd/blob/master/src/toir.d#L820
The problem is the closure is generated when it is expected that the delegate
will survive past the end of the scope (it's the whole point of a closure). But
with a destructor that runs at the end of the scope, it cannot survive, and so
the user of the closure will be referring to a destroyed object.
There is a current PR to improve the closure decision so that fewer closures are
necessary,
https://github.com/dlang/dmd/pull/5972
I don't know if that will resolve the issue you're having.
(A smaller test case would be nice!)
More information about the Digitalmars-d-learn
mailing list