1 /* 2 REQUIRED_ARGS: -dip1000 3 TEST_OUTPUT: 4 --- 5 fail_compilation/test17422.d(23): Error: scope variable `p` may not be returned 6 --- 7 */ 8 struct RC 9 { 10 Object get() return scope @trusted 11 { 12 return cast(Object) &store[0]; 13 } 14 15 private: 16 ubyte[__traits(classInstanceSize, Object)] store; 17 } 18 test()19Object test() @safe 20 { 21 RC rc; 22 auto p = rc.get; // p must be inferred as scope variable, works for int* 23 return p; 24 } 25