mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
The condition of a do-while loop can use variables declared in the loop (variables can only be declared inside a block). Previously this behaviour caused crash because after the block was generated, all variables declared inside that block were gone from myFrameMap #KT-3280 Fixed
25 lines
356 B
Kotlin
Vendored
25 lines
356 B
Kotlin
Vendored
fun foo() {
|
|
var x = 0
|
|
do {
|
|
x++
|
|
var y = x + 5
|
|
} while (y < 10)
|
|
if (x != 5) throw AssertionError("$x")
|
|
}
|
|
|
|
fun bar() {
|
|
var b = false
|
|
do {
|
|
var x = "X"
|
|
var y = "Y"
|
|
b = true
|
|
} while (x + y != "XY")
|
|
if (!b) throw AssertionError()
|
|
}
|
|
|
|
fun box(): String {
|
|
foo()
|
|
bar()
|
|
return "OK"
|
|
}
|