-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vet regression case from update #68
Comments
Other variants: ifpackage sandbox
import (
"io"
"net/http"
)
func Foo(req *http.Request) error {
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode == 200 {
return nil
}
io.ReadAll(res.Body)
return nil
} forpackage sandbox
import (
"io"
"net/http"
)
func Foo(req *http.Request) error {
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
for range res.StatusCode {
return nil
}
io.ReadAll(res.Body)
return nil
} switchpackage sandbox
import (
"io"
"net/http"
)
func Foo(req *http.Request) error {
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
switch res.StatusCode {
case http.StatusOK:
return nil
}
io.ReadAll(res.Body)
return nil
} |
The problem is related to the way the graph is analyzed: the algorithm is always wrong if there is at least one |
Seems like it needs to be updated such that it doesn't fail if the parent branch explicitly calls the I tested the below cases as well and got fails: Defer Close with "named" block
package sandbox
import (
"net/http"
)
func Foo(req *http.Request) error {
res, err := http.DefaultClient.Do(req)
if err != nil {
// even though in practice this wouldn't be done, was checking to see if it was this block causing issue
res.Body.Close()
return err
}
defer res.Body.Close()
{
_ = res.Body
}
return nil
} Fails with:
Explicit Close with "named" block
package sandbox
import (
"net/http"
)
func Foo(req *http.Request) error {
res, err := http.DefaultClient.Do(req)
if err != nil {
// even though in practice this wouldn't be done, was checking to see if it was this block causing issue
res.Body.Close()
return err
}
{
_ = res.Body
}
err = res.Body.Close()
if err != nil {
return err
}
return nil
} Fails with:
|
Seeing stuff that didn't fail on ed6a65f now failing on current commit.
Example:
integrations/testbodyclose/test.go
Passes on ed6a65f, but fails with:
on master commit.
Can provide more examples similar to this if necessary, but would need to dig them up so didn't include in initial.
The text was updated successfully, but these errors were encountered: