Add tests for guarding functions proxied by a variable

Negation doesn't appear to be handled correctly, so one
of the lines is marked as a false positive.
This commit is contained in:
Owen Mansel-Chan
2021-01-20 14:35:45 +00:00
parent fbe0474d0c
commit b623a4c8ec

View File

@@ -825,4 +825,27 @@ func test() {
}
}
// Note we can also assign the result of a guarding function to a variable and use that in
// the conditional.
{
s := source()
isInvalid := guardBool(s)
if isInvalid {
sink(s) // $dataflow=s
} else {
sink(s)
}
}
{
s := source()
isValid := !guardBool(s)
if isValid {
sink(s) // $f+:dataflow=s
} else {
sink(s) // $dataflow=s
}
}
}