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

Support validator patterns #212

Open
yuxincs opened this issue Mar 5, 2024 · 0 comments
Open

Support validator patterns #212

yuxincs opened this issue Mar 5, 2024 · 0 comments
Labels
false positive Requires more analysis and support

Comments

@yuxincs
Copy link
Contributor

yuxincs commented Mar 5, 2024

NilAway currently does not track the side effects of validator functions:

//nilable(a)
func validate(a *int) bool {
	return a != nil
}

//nilable(a)
func foo(a *int) {
	if validate(a) {
		// `a` should be nonnil now.
		print(*a)
	}
}

But NilAway complains

unexpected diagnostic: Potential nil panic detected. Observed nil flow from source to dereference point: 
        	- foo.go:31:10: function parameter `a` dereferenced

It could also be the case that the validate function validates certain fields of a struct and returns a boolean variable. Tracking this kind of side effects could be expensive, and we should think of a smart way to handle this in an efficient manner.

@yuxincs yuxincs added the false positive Requires more analysis and support label Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false positive Requires more analysis and support
Projects
None yet
Development

No branches or pull requests

1 participant