Disallow break or continue across a function boundary

Code containing breaks or continues that attempt to jump across a
function boundary weren't detected during analysis but would crash
the compiler during code generation. Add diagnostics for these kinds
of errors.

Example:

fun f() {
    while (true) {
        fun inner() {
            continue
        }
    }
}

 #KT-4334 Fixed
This commit is contained in:
Tuomas Tynkkynen
2014-02-24 20:31:19 +02:00
parent 7c8910bef6
commit 3e451c5811
7 changed files with 42 additions and 1 deletions
@@ -3,6 +3,6 @@ package b
fun foo() {
for (i in <!UNRESOLVED_REFERENCE!>collection<!>) {
<!UNUSED_FUNCTION_LITERAL!>{
break
<!BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY!>break<!>
}<!>
}<!SYNTAX!><!>