Skip to content
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

False negative result #247

Closed
potalestor opened this issue May 20, 2024 · 1 comment
Closed

False negative result #247

potalestor opened this issue May 20, 2024 · 1 comment
Labels
feature structinit Requires struct initialization support

Comments

@potalestor
Copy link

package main

import "fmt"

type S struct {
	a *int
}

func main() {
	s := &S{}

	fmt.Println(*s.a)
}
@potalestor potalestor changed the title False negavive result False negative result May 20, 2024
@sonalmahajan15
Copy link
Contributor

@potalestor, thanks for reporting! Currently the core NilAway does not reason too much about struct fields, especially struct initializations (e.g., creating empty structs or creating empty structs and then use a helper function to properly populate the struct fields). However, we have an extension within NilAway that reason struct fields up to depth one, making NilAway capable of handling code examples in this issue.

We have not enabled it since it increases build-time overhead to be slightly >5% (under our internal testing), and also because this capability may report more false positives. We are actively working on applying more optimizations and false positive reduction to enable and integrate, but we are not there yet.

With all that said, if you would like to try it out, you can add a <nilaway struct enable> in the file's docstring to enable this feature for this file in particular. Or this feature is also available for experimentation with the config flag experimental-struct-init (https://github.com/uber-go/nilaway/wiki/Configuration#experimental-struct-init).

(Closing this issue for now, but feel free to reopen it if you would like to report more problems.)

@sonalmahajan15 sonalmahajan15 added the feature structinit Requires struct initialization support label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature structinit Requires struct initialization support
Projects
None yet
Development

No branches or pull requests

2 participants