summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/runnable/test21479.d
blob: 84612ab49eaa469af21c49c2601a76ea2a599534 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// https://issues.dlang.org/show_bug.cgi?id=21479
enum Side
{
    left,
    right
}

struct Both(T)
{
    T left;
    T right;

    ref T get(Side side)
    {
        return side == Side.left ? left : right;
    }
}

void main()
{
    Both!(int[]) t;
    t.get(Side.left) ~= 1;
    assert (t.left.length == 1);

    t.get(Side.right) ~= 1;
    t.get(Side.right) ~= 2;
    assert (t.right.length == 2);
}