MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail12378.d
blob77678ebc0fc08e757f224734ba0f15eb054b6241
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: `__lambda1!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 ---
13 void testS()
15 auto r =
16 iota(1).mapS!(y0 =>
17 iota(2).mapS!(x0 =>
18 ANYTHING-GOES
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: `__lambda1!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 ---
35 void testC()
37 auto r =
38 iota(1).mapC!(y0 =>
39 iota(2).mapC!(x0 =>
40 ANYTHING-GOES
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: `__lambda1!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 ---
59 void testI()
61 auto r =
62 iota(1).mapI!(y0 =>
63 iota(2).mapI!(x0 =>
64 ANYTHING-GOES
69 auto iota(E)(E end)
71 alias Value = E;
73 static struct Result
75 private Value current, pastLast;
77 @property inout(Value) front() inout { return current; }
80 return Result(0, end);
83 template mapS(fun...)
85 auto mapS(R)(R r)
87 alias AppliedReturnType(alias f) = typeof(f(r.front));
88 static assert(!is(AppliedReturnType!fun == void),
89 "Mapping function must not return void.");
91 return MapResultS!(fun, R)(r);
94 struct MapResultS(alias fun, R)
96 R _input;
98 @property auto ref front()
100 return fun(_input.front);
104 template mapC(fun...)
106 auto mapC(R)(R r)
108 alias AppliedReturnType(alias f) = typeof(f(r.front));
109 static assert(!is(AppliedReturnType!fun == void),
110 "Mapping function must not return void.");
112 return new MapResultC!(fun, R)(r);
115 class MapResultC(alias fun, R)
117 R _input;
119 this(R r) { _input = r; }
121 @property auto ref front()
123 return fun(_input.front);
127 template mapI(fun...)
129 auto mapI(R)(R r)
131 alias AppliedReturnType(alias f) = typeof(f(r.front));
132 static assert(!is(AppliedReturnType!fun == void),
133 "Mapping function must not return void.");
135 return MapResultI!(fun, R).init;
138 interface MapResultI(alias fun, R)
140 static @property auto ref front()
142 R _input;
143 return fun(_input.front);