Skip to content

Commit 352c20b

Browse files
authored
Merge pull request #10885 from tamasvajk/kotlin-const-loop-cond-fp
Kotlin: Add test case for false positive with modified captured variable
2 parents cf35299 + 9d1af76 commit 352c20b

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fun fn0(f: Function0<Unit>) = f()
2+
3+
fun fn1() {
4+
var c = true
5+
while (c) { // TODO: false positive
6+
fn0 {
7+
c = false
8+
}
9+
}
10+
11+
var d = true
12+
while (d) {
13+
fn0 {
14+
println(d)
15+
}
16+
}
17+
18+
val e = true
19+
while (e) {
20+
fn0 {
21+
println(e)
22+
}
23+
}
24+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| 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 |
2+
| 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 |
3+
| 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 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Likely Bugs/Termination/ConstantLoopCondition.ql

0 commit comments

Comments
 (0)