Test case: ``` template AliasSeq(Args...) { alias Args AliasSeq; } struct S { int a, b; alias AliasSeq!(b, a) expandReverse; } unittest { S obj; int a, b; obj.expandReverse = AliasSeq!(b, a); // error: need `this` for`b` ... } ``` The only option currently where accessing a tuple doesn't lose `this` is the following solution: ``` template AliasSeq(Args...) { alias Args AliasSeq; } struct S { AliasSeq!(int, int) expand; // this has worked since forever it seems } unittest { S obj; int a, b; obj.expand = AliasSeq!(a, b); } ```
If a member tuple contains functions and this tuple is unpacked with a foreach statement then there is current usage that would break if `this` is preserved. ``` alias AliasSeq(Args...) = Args; struct S { void f() {} alias funcs = AliasSeq!(f); } unittest { S obj; foreach (f; obj.funcs) // obj.funcs is expanded into S.f not obj.f pragma(msg, typeof(f)); } ```
@SSoulaimane updated dlang/dmd pull request #10702 "Fix issue 20470 - Keep `this` when accessing tuple members" fixing this issue: - Fix issue 20470 - Keep `this` when accessing tuple members Expand `m.tuple(a, b)` into `tuple(m.a, m.b)` https://github.com/dlang/dmd/pull/10702
dlang/dmd pull request #10702 "Fix issue 20470 - Keep `this` when accessing tuple members" was merged into master: - 33941f0400ed0842cbfc68bd43295b948691a5f8 by سليمان السهمي (Suleyman Sahmi): Fix issue 20470 - Keep `this` when accessing tuple members Expand `m.tuple(a, b)` into `tuple(m.a, m.b)` https://github.com/dlang/dmd/pull/10702