blob: 5f371da46c8bb20c88feef4d50f9a60d631c735d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/* REQUIRED_ARGS: -preview=dip1000
* TEST_OUTPUT:
---
fail_compilation/fail17927.d(13): Error: scope variable `this` may not be returned
fail_compilation/fail17927.d(15): Error: scope variable `this` may not be returned
fail_compilation/fail17927.d(21): Error: scope variable `ptr` may not be returned
fail_compilation/fail17927.d(23): Error: scope variable `ptr` may not be returned
---
*/
// https://issues.dlang.org/show_bug.cgi?id=17927
struct String {
const(char)* mem1() const scope @safe { return ptr; }
inout(char)* mem2() inout scope @safe { return ptr; } // no error because `ref inout` implies `return`
char* ptr;
}
const(char)* foo1(scope const(char)* ptr) @safe { return ptr; }
inout(char)* foo2(scope inout(char)* ptr) @safe { return ptr; }
|