Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/fail12378.d

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail12378.d(18): Error: undefined identifier `ANYTHING`
5 fail_compilation/fail12378.d(18): Error: undefined identifier `GOES`
6 fail_compilation/fail12378.d(91): instantiated from here: `MapResultS!((x0) => ANYTHING - GOES, Result)`
7 fail_compilation/fail12378.d(17): instantiated from here: `mapS!(Result)`
8 fail_compilation/fail12378.d(100): instantiated from here: `__lambda_L16_C19!int`
9 fail_compilation/fail12378.d(91): instantiated from here: `MapResultS!((y0) => iota(2).mapS!((x0) => ANYTHING - GOES), Result)`
10 fail_compilation/fail12378.d(16): instantiated from here: `mapS!(Result)`
11 ---
12 */
13 void testS()
14 {
15 auto r =
16 iota(1).mapS!(y0 =>
17 iota(2).mapS!(x0 =>
18 ANYTHING-GOES
19 )
20 );
21 }
22
23 /*
24 TEST_OUTPUT:
25 ---
26 fail_compilation/fail12378.d(40): Error: undefined identifier `ANYTHING`
27 fail_compilation/fail12378.d(40): Error: undefined identifier `GOES`
28 fail_compilation/fail12378.d(112): instantiated from here: `MapResultC!((x0) => ANYTHING - GOES, Result)`
29 fail_compilation/fail12378.d(39): instantiated from here: `mapC!(Result)`
30 fail_compilation/fail12378.d(123): instantiated from here: `__lambda_L38_C19!int`
31 fail_compilation/fail12378.d(112): instantiated from here: `MapResultC!((y0) => iota(2).mapC!((x0) => ANYTHING - GOES), Result)`
32 fail_compilation/fail12378.d(38): instantiated from here: `mapC!(Result)`
33 ---
34 */
35 void testC()
36 {
37 auto r =
38 iota(1).mapC!(y0 =>
39 iota(2).mapC!(x0 =>
40 ANYTHING-GOES
41 )
42 );
43 }
44
45 /*
46 TEST_OUTPUT:
47 ---
48 fail_compilation/fail12378.d(64): Error: undefined identifier `ANYTHING`
49 fail_compilation/fail12378.d(64): Error: undefined identifier `GOES`
50 fail_compilation/fail12378.d(135): instantiated from here: `MapResultI!((x0) => ANYTHING - GOES, Result)`
51 fail_compilation/fail12378.d(63): instantiated from here: `mapI!(Result)`
52 fail_compilation/fail12378.d(143): instantiated from here: `__lambda_L62_C19!int`
53 fail_compilation/fail12378.d(135): instantiated from here: `MapResultI!((y0) => iota(2).mapI!((x0) => ANYTHING - GOES), Result)`
54 fail_compilation/fail12378.d(62): instantiated from here: `mapI!(Result)`
55 ---
56 */
57
58
59 void testI()
60 {
61 auto r =
62 iota(1).mapI!(y0 =>
63 iota(2).mapI!(x0 =>
64 ANYTHING-GOES
65 )
66 );
67 }
68
69 auto iota(E)(E end)
70 {
71 alias Value = E;
72
73 static struct Result
74 {
75 private Value current, pastLast;
76
77 @property inout(Value) front() inout { return current; }
78 }
79
80 return Result(0, end);
81 }
82
83 template mapS(fun...)
84 {
85 auto mapS(R)(R r)
86 {
87 alias AppliedReturnType(alias f) = typeof(f(r.front));
88 static assert(!is(AppliedReturnType!fun == void),
89 "Mapping function must not return void.");
90
91 return MapResultS!(fun, R)(r);
92 }
93 }
94 struct MapResultS(alias fun, R)
95 {
96 R _input;
97
98 @property auto ref front()
99 {
100 return fun(_input.front);
101 }
102 }
103
104 template mapC(fun...)
105 {
106 auto mapC(R)(R r)
107 {
108 alias AppliedReturnType(alias f) = typeof(f(r.front));
109 static assert(!is(AppliedReturnType!fun == void),
110 "Mapping function must not return void.");
111
112 return new MapResultC!(fun, R)(r);
113 }
114 }
115 class MapResultC(alias fun, R)
116 {
117 R _input;
118
119 this(R r) { _input = r; }
120
121 @property auto ref front()
122 {
123 return fun(_input.front);
124 }
125 }
126
127 template mapI(fun...)
128 {
129 auto mapI(R)(R r)
130 {
131 alias AppliedReturnType(alias f) = typeof(f(r.front));
132 static assert(!is(AppliedReturnType!fun == void),
133 "Mapping function must not return void.");
134
135 return MapResultI!(fun, R).init;
136 }
137 }
138 interface MapResultI(alias fun, R)
139 {
140 static @property auto ref front()
141 {
142 R _input;
143 return fun(_input.front);
144 }
145 }