Or similar problem: class Foo{}
struct Slice{ Foo[] data; this(return scope Foo[] data)@safe { this.data = data; } Slice opSlice()@safe return scope{ return Slice(data); } Foo opIndex(size_t i)@safe return scope{ return data[i]; } } void main()@safe{ Foo foo; scope Slice slice = Slice([new Foo]); foo = slice[][0]; //OK, Why?foo = slice[].opIndex(0); //Error: scope variable slice assigned to foo with longer lifetime
}