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

--- Comment #2 from João Lourenço <[email protected]> ---
Yes the last 2 make sense to infer scope, the comments were because I'm
specifying other templates with `(this This)` and they cannot infer scope.

> but canInfer3 and canInfer4 succeed because the parameter (This bar) in the 
> lambda is inferred scope since it's passed by value and the lambda is `pure` 
> and returns `void`, so it can't escape `arr`.

Ok, but I can make it a function and still escape its context:

```
@safe:

struct Bar
{
    void canInfer(this This)()
    {
        This other;
        (This bar) { other = bar; } (this);
        with(other) cast(void) &i; 
    }

    int[] arr = [0];
    int i;
}

void main()
{
    scope bar = Bar();
        bar.canInfer;
}
```

--

Reply via email to