MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / ice12174.d
blobdbe386e97e996d1f129fe2893c574c87db7f4ff1
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/ice12174.d(12): Error: no property `sum` for `[1, 2, 3]` of type `int[]`
5 fail_compilation/ice12174.d(20): Error: CTFE failed because of previous errors in `this`
6 fail_compilation/ice12174.d(13): called from here: `filter([1, 2, 3])`
7 ---
8 */
10 void main()
12 enum foo3 = (int n) => [1,2,3].sum;
13 enum bar3 = [1,2,3].filter!(n => n % foo3(n) == 0);
16 template filter(alias pred)
18 auto filter(Range)(Range rs)
20 return FilterResult!(pred, Range)(rs);
24 private struct FilterResult(alias pred, R)
26 R _input;
28 this(R r)
30 _input = r;
31 while (_input.length && !pred(_input[0]))
33 _input = _input[1..$];
37 @property bool empty() { return _input.length == 0; }
39 @property auto ref front()
41 return _input[0];
44 void popFront()
48 _input = _input[1..$];
49 } while (_input.length && !pred(_input[0]));