Re: scope variable `b` assigned to `a` with longer lifetime (-dip1000)

2022-04-09 Thread Dennis via Digitalmars-d-learn
On Saturday, 9 April 2022 at 10:39:33 UTC, vit wrote: Why doesn't this code compile? `proxySwap1` is lying about its attributes. It says `rhs` is `scope`, but it escapes by assignment `this.ptr = rhs.ptr;`. The compiler doesn't raise an error because it's marked `@trusted`. `proxySwap2` is

scope variable `b` assigned to `a` with longer lifetime (-dip1000)

2022-04-09 Thread vit via Digitalmars-d-learn
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)