Debian Codegraph @

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

raw
1 /* REQUIRED_ARGS: -preview=dip1000
2 TEST_OUTPUT:
3 ---
4 fail_compilation/test18644.d(15): Error: escaping a `scope` value returned from nested function `foo` into allocated memory is not allowed in a `@safe` function
5 fail_compilation/test18644.d(16): Error: escaping local variable through nested function `foo` is not allowed in a `@safe` function
6 fail_compilation/test18644.d(22): Error: escaping local variable through nested function `foo` is not allowed in a `@safe` function
7 ---
8 */
9
10 // https://issues.dlang.org/show_bug.cgi?id=18644
11
12 @safe int* test1() {
13 int i;
14 int* foo() { return &i; }
15 int*[] b = [foo()];
16 return foo();
17 }
18
19 @safe ref int test2() {
20 int i;
21 ref int foo() { return i; }
22 return foo();
23 }