Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail11125.d(26): Error: template instance `fail11125.filter!(function (int a) pure nothrow @nogc @safe => a + 1)` does not match template declaration `filter(alias predfun)`
5 with `predfun = (int a) => a + 1`
6 must satisfy the following constraint:
7 ` is(ReturnType!predfun == bool)`
8 fail_compilation/fail11125.d(27): Error: template instance `fail11125.filter!(function (int a) pure nothrow @nogc @safe => a + 1)` does not match template declaration `filter(alias predfun)`
9 with `predfun = (int a) => a + 1`
10 must satisfy the following constraint:
11 ` is(ReturnType!predfun == bool)`
12 ---
13 */
14
15 template ReturnType(alias fun) { alias int ReturnType; }
16
17 template filter(alias predfun)
18 if (is(ReturnType!predfun == bool))
19 {
20 static assert(is(ReturnType!predfun == bool));
21 auto filter(Range)(Range r) { }
22 }
23
24 void main()
25 {
26 filter!((int a) => a + 1)([1]); // fails in constraint
27 [1].filter!((int a) => a + 1); // fails internally in static assert!
28 }