summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/ice14096.d
blob: 654cfcc798916699a02690ec91a5ed53ff4d5e56 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
TEST_OUTPUT:
---
fail_compilation/ice14096.d(29): Error: cannot access frame pointer of ice14096.main.Baz!((i) => i).Baz
fail_compilation/ice14096.d(23): Error: template instance ice14096.foo!(Tuple!(Baz!((i) => i))).foo.bar!(t) error instantiating
fail_compilation/ice14096.d(40):        instantiated from here: foo!(Tuple!(Baz!((i) => i)))
---
*/

struct Tuple(Types...)
{
    Types expand;
    alias expand this;
    alias field = expand;
}
Tuple!T tuple(T...)(T args)
{
    return typeof(return)(args);
}

auto foo(T)(T t)
{
    bar!t();
}

auto bar(alias s)()
{
    // default construction is not possible for: Tuple!(Baz!(i => i))
    typeof(s) p;
}

struct Baz(alias f)
{
    void g() {}
}

void main()
{
    auto t = tuple(Baz!(i => i)());
    foo(t);
}