"Fossies" - the Fresh Open Source Software Archive

Member "dmd-2.089.0/test/fail_compilation/fail13116.d" (2 Nov 2019, 478 Bytes) of package /linux/misc/dmd-2.089.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2 TEST_OUTPUT:
    3 ---
    4 fail_compilation/fail13116.d(14): Error: `this` is not an lvalue and cannot be modified
    5 fail_compilation/fail13116.d(23): Error: `super` is not an lvalue and cannot be modified
    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 }