Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail13116.d(14): Error: cannot `ref` return expression `this` because it is not an lvalue
5 fail_compilation/fail13116.d(23): Error: cannot `ref` return expression `super` because it is not an lvalue
6 ---
7 */
8 struct S
9 {
10 ref S notEvil() return { return this; } // this should be accepted
11 }
12 class C
13 {
14 ref C evil() { return this; } // this should be rejected
15 }
16 void main()
17 {
18 }
19
20 class Base { }
21 class Derived : Base
22 {
23 ref Base evil() { return super; } // should be rejected
24 }