Kotlin: Add test case for variables named underscore

This commit is contained in:
Tamas Vajk
2022-10-24 09:04:54 +02:00
parent ac013f9d19
commit 0192ae8331
5 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
fun fn() {
try {
val l = listOf(1, 2, 3)
l.forEachIndexed { index, _ -> println(index) }
val p = Pair(1, 2)
val (first, _) = p
} catch (_: Exception) {
// expected
}
}

View File

@@ -0,0 +1 @@
| Test.kt:8:14:8:25 | Exception _ | Use of underscore as a one-character identifier. |

View File

@@ -0,0 +1 @@
Compatibility/JDK9/UnderscoreIdentifier.ql

View File

@@ -0,0 +1,7 @@
| Test.kt:3:9:3:31 | List<Integer> l |
| Test.kt:4:28:4:32 | index |
| Test.kt:4:35:4:35 | p1 |
| Test.kt:6:9:6:26 | Pair<Integer,Integer> p |
| Test.kt:7:14:7:18 | int first |
| Test.kt:7:26:7:26 | Pair<Integer,Integer> tmp0_container |
| Test.kt:8:14:8:25 | Exception _ |

View File

@@ -0,0 +1,3 @@
import java
query predicate variables(Variable v) { v.fromSource() }