Skip to content

Commit 0192ae8

Browse files
committed
Kotlin: Add test case for variables named underscore
1 parent ac013f9 commit 0192ae8

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fun fn() {
2+
try {
3+
val l = listOf(1, 2, 3)
4+
l.forEachIndexed { index, _ -> println(index) }
5+
6+
val p = Pair(1, 2)
7+
val (first, _) = p
8+
} catch (_: Exception) {
9+
// expected
10+
}
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| Test.kt:8:14:8:25 | Exception _ | Use of underscore as a one-character identifier. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Compatibility/JDK9/UnderscoreIdentifier.ql
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
| Test.kt:3:9:3:31 | List<Integer> l |
2+
| Test.kt:4:28:4:32 | index |
3+
| Test.kt:4:35:4:35 | p1 |
4+
| Test.kt:6:9:6:26 | Pair<Integer,Integer> p |
5+
| Test.kt:7:14:7:18 | int first |
6+
| Test.kt:7:26:7:26 | Pair<Integer,Integer> tmp0_container |
7+
| Test.kt:8:14:8:25 | Exception _ |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import java
2+
3+
query predicate variables(Variable v) { v.fromSource() }

0 commit comments

Comments
 (0)