www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20470] New: accessing an AliasSeq tuple loses `this`

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

          Issue ID: 20470
           Summary: accessing an AliasSeq tuple loses `this`
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: sahmi.soulaimane gmail.com

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);
}
```

--
Dec 30 2019