Hello,
Why doesn't this code compile?

```d

static struct Foo{
    void *ptr;

void proxySwap1(scope ref typeof(this) rhs)scope pure nothrow @trusted @nogc{
        auto tmp = this.ptr;
        this.ptr = rhs.ptr;
        rhs.ptr = tmp;
    }
void proxySwap2()(scope ref typeof(this) rhs)scope pure nothrow @trusted @nogc{
        this.proxySwap1(rhs);
    }
void proxySwap3()(scope ref typeof(this) rhs)scope pure nothrow @trusted @nogc{
        auto tmp = this.ptr;
        this.ptr = rhs.ptr;
        rhs.ptr = tmp;
    }
}

void main()@safe{

    scope Foo a;
    scope Foo b;

    a.proxySwap1(b);    //OK
    a.proxySwap2(b);    //OK
a.proxySwap3(b); //Error: scope variable `b` assigned to `a` with longer lifetime
}
```

Reply via email to