"Fossies" - the Fresh Open Source Software Archive

Member "dmd-2.089.0/test/fail_compilation/fail2962.d" (2 Nov 2019, 867 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 // EXTRA_SOURCES: imports/fail2962a.d
    2 
    3 // comment 6
    4 /*
    5 TEST_OUTPUT:
    6 ---
    7 fail_compilation/fail2962.d(14): Error: variable `y` cannot be read at compile time
    8 fail_compilation/fail2962.d(14):        while looking for match for `baz6!(int, y)`
    9 fail_compilation/fail2962.d(22): Error: template instance `fail2962.bar6!int` error instantiating
   10 ---
   11 */
   12 T bar6(T)(T y)
   13 {
   14     return baz6!(T, y)();
   15 }
   16 T baz6(T, T z)()
   17 {
   18     return z * z;
   19 }
   20 void test6()
   21 {
   22     assert(bar6(4) != 0);
   23 }
   24 
   25 // comment 4
   26 /*
   27 TEST_OUTPUT:
   28 ---
   29 fail_compilation/fail2962.d(36): Error: variable `x` cannot be read at compile time
   30 fail_compilation/fail2962.d(36):        while looking for match for `baz4!(int, x)`
   31 fail_compilation/imports/fail2962a.d(6): Error: template instance `fail2962.bar4!int` error instantiating
   32 ---
   33 */
   34 T bar4(T)(T x)
   35 {
   36     return baz4!(T, x)();
   37 }
   38 T baz4(T, T x)()
   39 {
   40     return x;
   41 }