mirror of
https://github.com/github/codeql.git
synced 2026-01-29 14:23:03 +01:00
Correctly create extract nodes for returns where we cannot infer the type of the returned expression, but know from context that it must be a tuple type.
This commit is contained in:
@@ -114,9 +114,14 @@ newtype TControlFlowNode =
|
||||
)
|
||||
or
|
||||
// in a return statement `return f()` where `f` has multiple return values
|
||||
exists(ReturnStmt ret, CallExpr call | s = ret |
|
||||
call = ret.getExpr().stripParens() and
|
||||
exists(call.getType().(TupleType).getComponentType(i))
|
||||
exists(ReturnStmt ret, SignatureType rettp |
|
||||
s = ret and
|
||||
// the return statement has a single expression
|
||||
exists(ret.getExpr()) and
|
||||
// but the enclosing function has multiple results
|
||||
rettp = ret.getEnclosingFunction().getType() and
|
||||
rettp.getNumResult() > 1 and
|
||||
exists(rettp.getResultType(i))
|
||||
)
|
||||
or
|
||||
// in a call `f(g())` where `g` has multiple return values
|
||||
|
||||
@@ -31,3 +31,7 @@ func test2(x int) (int, int) {
|
||||
z := x % (1)
|
||||
return z, y % 13
|
||||
}
|
||||
|
||||
func test3() (x int, y int) {
|
||||
return unknownFunction()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user