Files
kotlin/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryCatchAfterWhileTrue.kt
Denis Zharkov ff0736f09e Fix exception after combination of while (true) + stack-spilling
FixStack transformation divides on phases:
- Fixing stack before break/continue
- Fixing stack for inline markers/try-catch blocks

After the first stage all ALWAYS_TRUE markers are replaced
with simple GOTO's and if we're skipping break/continue edges
we won't reach the code after while (true) statement.

At the same time it's fine to not to skip them in the second phase
as the stack for them is already corrected in the first phase

 #KT-19475 Fixed
2017-08-08 18:52:21 +07:00

19 lines
304 B
Kotlin
Vendored

// WITH_RUNTIME
fun box(): String {
val a = arrayListOf<String>()
while (true) {
if (a.size == 0) {
break
}
}
for (i in 1..2) {
a.add(try { foo() } catch (e: Throwable) { "OK" })
}
return a[0]
}
fun foo(): String = throw RuntimeException()