mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Kotlin: Add test case for variables named underscore
This commit is contained in:
11
java/ql/test/kotlin/query-tests/UnderscoreIdentifier/Test.kt
Normal file
11
java/ql/test/kotlin/query-tests/UnderscoreIdentifier/Test.kt
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
| Test.kt:8:14:8:25 | Exception _ | Use of underscore as a one-character identifier. |
|
||||
@@ -0,0 +1 @@
|
||||
Compatibility/JDK9/UnderscoreIdentifier.ql
|
||||
@@ -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 _ |
|
||||
@@ -0,0 +1,3 @@
|
||||
import java
|
||||
|
||||
query predicate variables(Variable v) { v.fromSource() }
|
||||
Reference in New Issue
Block a user