Add tests for extracting tuples in f(g(...))

This commit is contained in:
Owen Mansel-Chan
2025-05-13 15:54:05 +01:00
parent b06491125e
commit 7da1ade835
2 changed files with 15 additions and 0 deletions

View File

@@ -4,3 +4,7 @@
| test.go:15:2:15:20 | ... := ...[1] | test.go:15:13:15:20 | index expression | 1 | file://:0:0:0:0 | bool |
| test.go:21:2:21:22 | ... := ...[0] | test.go:21:13:21:22 | type assertion | 0 | file://:0:0:0:0 | string |
| test.go:21:2:21:22 | ... := ...[1] | test.go:21:13:21:22 | type assertion | 1 | file://:0:0:0:0 | bool |
| 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 |
| 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 |
| 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 |
| 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 |

View File

@@ -21,3 +21,14 @@ func testTypeAssert() {
got, ok := i.(string)
fmt.Printf("%v %v", got, ok)
}
func f(x, y int) {}
func g() (int, int) { return 0, 0 }
func testNestedFunctionCalls() {
f(g())
// Edge case: when we call a function from a variable, `getTarget()` is not defined
v := g
f(v())
}