d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / test21912.d
blobf8bcb40b5dfbe058368c7eaecbe1b5d8ab9adcdb
1 /*
2 PERMUTE_ARGS: -preview=dip1000
3 TEST_OUTPUT:
4 ---
5 fail_compilation/test21912.d(28): Error: function `test21912.escapeParam` is `@nogc` yet allocates closure for `escapeParam()` with the GC
6 fail_compilation/test21912.d(30): delegate `test21912.escapeParam.__lambda2` closes over variable `i`
7 fail_compilation/test21912.d(28): `i` declared here
8 fail_compilation/test21912.d(33): Error: function `test21912.escapeAssign` is `@nogc` yet allocates closure for `escapeAssign()` with the GC
9 fail_compilation/test21912.d(35): delegate `test21912.escapeAssign.__lambda3` closes over variable `i`
10 fail_compilation/test21912.d(33): `i` declared here
11 fail_compilation/test21912.d(44): Error: function `test21912.escapeAssignRef` is `@nogc` yet allocates closure for `escapeAssignRef()` with the GC
12 fail_compilation/test21912.d(46): delegate `test21912.escapeAssignRef.__lambda3` closes over variable `i`
13 fail_compilation/test21912.d(44): `i` declared here
14 fail_compilation/test21912.d(55): Error: function `test21912.escapeParamInferred` is `@nogc` yet allocates closure for `escapeParamInferred()` with the GC
15 fail_compilation/test21912.d(57): delegate `test21912.escapeParamInferred.__lambda2` closes over variable `i`
16 fail_compilation/test21912.d(55): `i` declared here
17 ---
19 @nogc:
21 alias Dg = @nogc int delegate();
23 Dg identity(return scope Dg dg)
25 return dg;
28 Dg escapeParam(int i)
30 return identity(() => i);
33 Dg escapeAssign(int i, return scope Dg dg)
35 dg = () => i;
36 return dg;
39 ref Dg identityR(return ref scope Dg dg)
41 return dg;
44 ref Dg escapeAssignRef(int i, return ref scope Dg dg)
46 dg = () => i;
47 return dg;
50 auto identityInferred(Dg dg)
52 return dg;
55 Dg escapeParamInferred(int i)
57 return identityInferred(() => i);