1 /* 2 TEST_OUTPUT: 3 --- 4 fail_compilation/fail6889.d(16): Error: cannot goto out of `scope(success)` block 5 fail_compilation/fail6889.d(17): Error: cannot goto in to `scope(success)` block 6 fail_compilation/fail6889.d(19): Error: return statements cannot be in `scope(success)` bodies 7 fail_compilation/fail6889.d(23): Error: continue is not inside `scope(success)` bodies 8 fail_compilation/fail6889.d(24): Error: break is not inside `scope(success)` bodies 9 fail_compilation/fail6889.d(29): Error: continue is not inside `scope(success)` bodies 10 fail_compilation/fail6889.d(30): Error: break is not inside `scope(success)` bodies 11 --- 12 */ test_success()13void test_success() 14 { 15 L1: 16 scope(success) { L2: goto L1; } // NG 17 goto L2; // NG 18 19 scope(success) { return; } // NG (from fail102.d) 20 21 foreach (i; 0..1) 22 { 23 scope(success) continue; // NG 24 scope(success) break; // NG 25 } 26 27 foreach (i; Aggr()) 28 { 29 scope(success) continue; // NG 30 scope(success) break; // NG 31 } 32 /+ 33 // is equivalent with: 34 switch ( 35 Aggr().opApply((int i){ 36 scope(success) return 0; // NG 37 scope(success) return 1; // NG 38 return 0; 39 })) 40 { 41 default: break; 42 } 43 +/ 44 } 45 46 /* 47 TEST_OUTPUT: 48 --- 49 fail_compilation/fail6889.d(56): Error: cannot goto in to `scope(failure)` block 50 --- 51 */ test_failure()52void test_failure() 53 { 54 L1: 55 scope(failure) { L2: goto L1; } // OK 56 goto L2; // NG 57 58 scope(failure) { return; } // OK 59 60 foreach (i; 0..1) 61 { 62 scope(failure) continue; // OK 63 scope(failure) break; // OK 64 } 65 66 foreach (i; Aggr()) 67 { 68 scope(failure) continue; // OK 69 scope(failure) break; // OK 70 } 71 /+ 72 // is equivalent with: 73 switch ( 74 Aggr().opApply((int i){ 75 scope(failure) return 0; // OK 76 scope(failure) return 1; // OK 77 return 0; 78 })) 79 { 80 default: break; 81 } 82 +/ 83 } 84 85 /* 86 TEST_OUTPUT: 87 --- 88 fail_compilation/fail6889.d(100): Error: cannot goto out of `scope(exit)` block 89 fail_compilation/fail6889.d(101): Error: cannot goto in to `scope(exit)` block 90 fail_compilation/fail6889.d(103): Error: return statements cannot be in `scope(exit)` bodies 91 fail_compilation/fail6889.d(107): Error: continue is not inside `scope(exit)` bodies 92 fail_compilation/fail6889.d(108): Error: break is not inside `scope(exit)` bodies 93 fail_compilation/fail6889.d(113): Error: continue is not inside `scope(exit)` bodies 94 fail_compilation/fail6889.d(114): Error: break is not inside `scope(exit)` bodies 95 --- 96 */ test_exit()97void test_exit() 98 { 99 L1: 100 scope(exit) { L2: goto L1; } // NG 101 goto L2; // NG 102 103 scope(exit) { return; } // NG (from fail102.d) 104 105 foreach (i; 0..1) 106 { 107 scope(exit) continue; // NG 108 scope(exit) break; // NG 109 } 110 111 foreach (i; Aggr()) 112 { 113 scope(exit) continue; // NG 114 scope(exit) break; // NG 115 } 116 /+ 117 // is equivalent with: 118 switch ( 119 Aggr().opApply((int i){ 120 scope(exit) return 0; // NG 121 scope(exit) return 1; // NG 122 return 0; 123 })) 124 { 125 default: break; 126 } 127 +/ 128 } 129 opApplyAggr130struct Aggr { int opApply(int delegate(int) dg) { return dg(0); } } 131