Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag13028.d(15): Error: variable `dg` cannot be read at compile time
5 fail_compilation/diag13028.d(22): Error: variable `a` cannot be read at compile time
6 fail_compilation/diag13028.d(28): Error: CTFE failed because of previous errors in `foo`
7 fail_compilation/diag13028.d(28): while evaluating: `static assert(foo(() pure nothrow @nogc @safe => 1) == 1)`
8 fail_compilation/diag13028.d(29): Error: CTFE failed because of previous errors in `bar`
9 fail_compilation/diag13028.d(29): while evaluating: `static assert(bar(delegate int() pure nothrow @nogc @safe => 1) == 1)`
10 ---
11 */
12
13 int foo(int delegate() dg)
14 {
15 enum b = dg();
16 return b;
17 }
18
19
20 int bar(lazy int a)
21 {
22 enum b = a;
23 return a;
24 }
25
26 void main()
27 {
28 static assert(foo(() => 1) == 1);
29 static assert(bar(1) == 1);
30 }