Merge pull request #10885 from tamasvajk/kotlin-const-loop-cond-fp

Kotlin: Add test case for false positive with modified captured variable
This commit is contained in:
Tamás Vajk
2022-10-21 10:08:02 +02:00
committed by GitHub
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
fun fn0(f: Function0<Unit>) = f()
fun fn1() {
var c = true
while (c) { // TODO: false positive
fn0 {
c = false
}
}
var d = true
while (d) {
fn0 {
println(d)
}
}
val e = true
while (e) {
fn0 {
println(e)
}
}
}

View File

@@ -0,0 +1,3 @@
| A.kt:5:12:5:12 | c | $@ might not terminate, as this loop condition is constant within the loop. | A.kt:5:5:9:5 | while (...) | Loop |
| A.kt:12:12:12:12 | d | $@ might not terminate, as this loop condition is constant within the loop. | A.kt:12:5:16:5 | while (...) | Loop |
| A.kt:19:12:19:12 | e | $@ might not terminate, as this loop condition is constant within the loop. | A.kt:19:5:23:5 | while (...) | Loop |

View File

@@ -0,0 +1 @@
Likely Bugs/Termination/ConstantLoopCondition.ql