1 /* REQUIRED_ARGS: -dip1000 2 PERMUTE_ARGS: 3 TEST_OUTPUT: 4 --- 5 fail_compilation/test14238.d(21): Error: scope variable `fn` may not be returned 6 fail_compilation/test14238.d(29): Error: escaping reference to stack allocated value returned by `&baz` 7 --- 8 */ 9 // https://issues.dlang.org/show_bug.cgi?id=14238 10 11 @safe: 12 13 alias Fn = ref int delegate() return; 14 foo(return scope Fn fn)15ref int foo(return scope Fn fn) 16 { 17 return fn(); // Ok 18 } 19 foo2(scope Fn fn)20ref int foo2(scope Fn fn) { 21 return fn(); // Error 22 } 23 bar()24ref int bar() { 25 int x; 26 ref int baz() { 27 return x; 28 } 29 return foo(&baz); 30 } 31