Files
kotlin/compiler/testData/diagnostics/testsWithStdLib/forInArrayLoop/forInFieldUpdatedInLoopBodyBefore13.fir.kt

16 lines
392 B
Kotlin
Vendored

// !LANGUAGE: -ProperForInArrayLoopRangeVariableAssignmentSemantic
// !DIAGNOSTICS: -UNUSED_VALUE
// SKIP_TXT
var xs: IntArray = intArrayOf(1, 2, 3)
get() = field
set(ys) {
var sum = 0
for (x in field) {
sum = sum * 10 + x
field = intArrayOf(4, 5, 6)
}
if (sum != 123) throw AssertionError("sum=$sum")
field = ys
}