2014-07-24 21:36:10 +02:00
|
|
|
==== tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts (6 errors) ====
|
2014-07-23 01:36:53 +02:00
|
|
|
// All errors
|
|
|
|
|
|
|
|
// naked break not allowed
|
|
|
|
break;
|
2014-07-24 21:36:10 +02:00
|
|
|
~~~~~~
|
2014-07-23 01:36:53 +02:00
|
|
|
!!! A 'break' statement can only be used within an enclosing iteration or switch statement.
|
|
|
|
|
|
|
|
// non-existent label
|
|
|
|
ONE:
|
|
|
|
while (true) break TWO;
|
2014-07-24 21:36:10 +02:00
|
|
|
~~~~~~~~~~
|
|
|
|
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
2014-07-23 01:36:53 +02:00
|
|
|
|
|
|
|
// break from inside function
|
|
|
|
TWO:
|
|
|
|
while (true){
|
|
|
|
var x = () => {
|
|
|
|
break TWO;
|
2014-07-24 21:36:10 +02:00
|
|
|
~~~~~~~~~~
|
|
|
|
!!! Jump target cannot cross function boundary.
|
2014-07-23 01:36:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
THREE:
|
|
|
|
while (true) {
|
|
|
|
var fn = function () {
|
|
|
|
break THREE;
|
2014-07-24 21:36:10 +02:00
|
|
|
~~~~~~~~~~~~
|
|
|
|
!!! Jump target cannot cross function boundary.
|
2014-07-23 01:36:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// break forward
|
|
|
|
while (true) {
|
|
|
|
break FIVE;
|
2014-07-24 21:36:10 +02:00
|
|
|
~~~~~~~~~~~
|
|
|
|
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
2014-07-23 01:36:53 +02:00
|
|
|
FIVE:
|
|
|
|
while (true) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
// label on non-loop statement
|
|
|
|
NINE:
|
|
|
|
var y = 12;
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
break NINE;
|
2014-07-24 21:36:10 +02:00
|
|
|
~~~~~~~~~~~
|
|
|
|
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
2014-07-23 01:36:53 +02:00
|
|
|
}
|