uber-go / nilaway

Static analysis tool to detect potential nil panics in Go code
Apache License 2.0
3.2k stars 66 forks source link

False negative in contract support #259

Open sonalmahajan15 opened 5 months ago

sonalmahajan15 commented 5 months ago

Below is a case of false negative when using non-literals. Replacing return x with return nil, works as expected

func fooReturn(x *int) *int {
    if x == nil {
        return x
    }
    return new(int)
}

func barReturn1(n int) {
    b1 := fooReturn(nil)
    print(*b1) // Expected: ERROR!
}