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 positive due to nilability of x determined by the value of y #292

Open
sonalmahajan15 opened this issue Nov 4, 2024 · 0 comments
Open
Labels
enhancement New feature or request false positive Requires more analysis and support

Comments

@sonalmahajan15
Copy link
Contributor

NilAway currently doesn't track nilability dependencies between 2 independent variables. This can result in false positives, such as in the example shown below. This is a hard problem, in general. We can perhaps think of adding intra-procedural support, which is a relatively tractable problem, leaving out inter-procedural tracking for the future.

func foo(x *int) {
	var y *int
	var z int

	if x != nil {
		y = x
		z = 1
	}

	if z == 1 {
		_ = *y  // FP reported here
	}
}

func test() {
	i := 1
	foo(&i)
}
@sonalmahajan15 sonalmahajan15 added enhancement New feature or request false positive Requires more analysis and support labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request false positive Requires more analysis and support
Projects
None yet
Development

No branches or pull requests

1 participant