1 /* 2 TEST_OUTPUT: 3 --- 4 fail_compilation/fail2456.d(14): Error: cannot put `scope(success)` statement inside finally block 5 --- 6 */ test_success()7void test_success() 8 { 9 try 10 { 11 } 12 finally 13 { 14 scope(success) {} // NG 15 } 16 } 17 18 /* 19 TEST_OUTPUT: 20 --- 21 fail_compilation/fail2456.d(31): Error: cannot put `scope(failure)` statement inside finally block 22 --- 23 */ test_failure()24void test_failure() 25 { 26 try 27 { 28 } 29 finally 30 { 31 scope(failure) {} // NG 32 } 33 } 34 35 /* 36 TEST_OUTPUT: 37 --- 38 --- 39 */ test_exit()40void test_exit() 41 { 42 try 43 { 44 } 45 finally 46 { 47 scope(exit) {} // OK 48 } 49 } 50 51 /* 52 TEST_OUTPUT: 53 --- 54 fail_compilation/fail2456.d(64): Error: cannot put `scope(success)` statement inside `scope(success)` 55 fail_compilation/fail2456.d(65): Error: cannot put `scope(failure)` statement inside `scope(success)` 56 fail_compilation/fail2456.d(78): Error: cannot put `scope(success)` statement inside `scope(exit)` 57 fail_compilation/fail2456.d(79): Error: cannot put `scope(failure)` statement inside `scope(exit)` 58 --- 59 */ test2456a()60void test2456a() 61 { 62 scope(success) 63 { 64 scope(success) {} // NG 65 scope(failure) {} // NG 66 scope(exit) {} // OK 67 } 68 69 scope(failure) 70 { 71 scope(success) {} // OK 72 scope(failure) {} // OK 73 scope(exit) {} // OK 74 } 75 76 scope(exit) 77 { 78 scope(success) {} // NG 79 scope(failure) {} // NG 80 scope(exit) {} // OK 81 } 82 } 83 84 /* 85 TEST_OUTPUT: 86 --- 87 fail_compilation/fail2456.d(96): Error: cannot put catch statement inside `scope(success)` 88 fail_compilation/fail2456.d(108): Error: cannot put catch statement inside `scope(exit)` 89 --- 90 */ test2456b()91void test2456b() 92 { 93 scope(success) 94 { 95 try {} 96 catch (Throwable) {} // NG 97 } 98 99 scope(failure) 100 { 101 try {} 102 catch (Throwable) {} // OK 103 } 104 105 scope(exit) 106 { 107 try {} 108 catch (Throwable) {} // NG 109 } 110 } 111