Skip to content

Commit 7da1ade

Browse files
committed
Add tests for extracting tuples in f(g(...))
1 parent b064911 commit 7da1ade

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

go/ql/test/library-tests/semmle/go/IR/test.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
| test.go:15:2:15:20 | ... := ...[1] | test.go:15:13:15:20 | index expression | 1 | file://:0:0:0:0 | bool |
55
| test.go:21:2:21:22 | ... := ...[0] | test.go:21:13:21:22 | type assertion | 0 | file://:0:0:0:0 | string |
66
| test.go:21:2:21:22 | ... := ...[1] | test.go:21:13:21:22 | type assertion | 1 | file://:0:0:0:0 | bool |
7+
| test.go:29:2:29:7 | call to f[0] | test.go:29:4:29:6 | call to g | 0 | file://:0:0:0:0 | int |
8+
| test.go:29:2:29:7 | call to f[1] | test.go:29:4:29:6 | call to g | 1 | file://:0:0:0:0 | int |
9+
| test.go:33:2:33:7 | call to f[0] | test.go:33:4:33:6 | call to v | 0 | file://:0:0:0:0 | int |
10+
| test.go:33:2:33:7 | call to f[1] | test.go:33:4:33:6 | call to v | 1 | file://:0:0:0:0 | int |

go/ql/test/library-tests/semmle/go/IR/test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ func testTypeAssert() {
2121
got, ok := i.(string)
2222
fmt.Printf("%v %v", got, ok)
2323
}
24+
25+
func f(x, y int) {}
26+
func g() (int, int) { return 0, 0 }
27+
28+
func testNestedFunctionCalls() {
29+
f(g())
30+
31+
// Edge case: when we call a function from a variable, `getTarget()` is not defined
32+
v := g
33+
f(v())
34+
}

0 commit comments

Comments
 (0)