Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // A break label must be declared where it's used. | 5 // A break label must be declared where it's used. |
| 6 undeclaredBreakLabel1() { | 6 undeclaredBreakLabel1() { |
| 7 foo: { break bar; break foo; } /// 01: compile-time error | 7 foo: { break bar; break foo; } /// 01: compile-time error |
| 8 } | 8 } |
| 9 | 9 |
| 10 undeclaredBreakLabel2() { | 10 undeclaredBreakLabel2() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 // Implicit break targets are not captured by closures. | 42 // Implicit break targets are not captured by closures. |
| 43 noncaptureBreak() { | 43 noncaptureBreak() { |
| 44 while(true) (() { break; })(); /// 08: compile-time error | 44 while(true) (() { break; })(); /// 08: compile-time error |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Implicit continue targets are not captured by closures. | 47 // Implicit continue targets are not captured by closures. |
| 48 noncaptureContinue() { | 48 noncaptureContinue() { |
| 49 while(true) (() { continue; })(); /// 09: compile-time error | 49 while(true) (() { continue; })(); /// 09: compile-time error |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Duplicate labels are reported as a warning only. | |
| 53 duplicateLabels() { | |
| 54 foo: { /// 10: compile-time error | |
|
floitsch
2012/02/20 19:01:54
compile-time error = warning?
Lasse Reichstein Nielsen
2012/02/21 13:53:56
Not really, that's why it's gone.
Also because it'
| |
| 55 foo: { /// 10: continued | |
| 56 return; /// 10: continued | |
| 57 break foo; /// 10: continued | |
| 58 } /// 10: continued | |
| 59 } /// 10: continued | |
| 60 } | |
| 61 | |
| 62 | |
| 63 // Unused labels are reported as a warning only. | |
| 64 unusedLabels() { | |
| 65 foo: { return; } /// 11: compile-time error | |
| 66 } | |
| 67 | |
| 68 | |
| 69 main() { | 52 main() { |
| 70 undeclaredBreakLabel1(); | 53 undeclaredBreakLabel1(); |
| 71 undeclaredBreakLabel2(); | 54 undeclaredBreakLabel2(); |
| 72 noBreakTarget(); | 55 noBreakTarget(); |
| 73 undeclaredContinueLabel(); | 56 undeclaredContinueLabel(); |
| 74 noContinueTarget(); | 57 noContinueTarget(); |
| 75 wrongContinueLabel(); | 58 wrongContinueLabel(); |
| 76 noncaptureLabel(); | 59 noncaptureLabel(); |
| 77 noncaptureBreak(); | 60 noncaptureBreak(); |
| 78 noncaptureContinue(); | 61 noncaptureContinue(); |
| 79 duplicateLabels(); | |
| 80 unusedLabels(); | |
| 81 } | 62 } |
| OLD | NEW |