Debian Codegraph @

gcc/testsuite/gdc.test/compilable/ice12554.d

raw
1 // REQUIRED_ARGS: -o-
2 // PERMUTE_ARGS:
3
4 void main() pure
5 {
6 int[] foo;
7
8 // if indirectly instantiated aggregate is struct (== MapResultS)
9 foo.map!(MapResultS, x => foo.map!(MapResultS, y => x).array);
10
11 // if indirectly instantiated aggregate is class (== MapResultC)
12 foo.map!(MapResultC, x => foo.map!(MapResultC, y => x).array);
13 }
14
15 T array(T)(T a)
16 {
17 static int g; g = 1; // impure operation
18 return a;
19 }
20
21 template map(alias MapResult, fun...)
22 {
23 auto map(Range)(Range r)
24 {
25 alias AppliedReturnType(alias f) = typeof(f(r[0]));
26 static assert(!is(AppliedReturnType!fun == void));
27
28 return MapResult!(fun).init;
29 }
30 }
31
32 struct MapResultS(alias fun)
33 {
34 @property front()
35 {
36 return fun(1);
37 }
38 }
39
40 class MapResultC(alias fun)
41 {
42 @property front()
43 {
44 return fun(1);
45 }
46 }