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 when there are already exhaustive combinations in switch cases #215

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

Comments

@yuxincs
Copy link
Contributor

yuxincs commented Mar 12, 2024

We already have support in NilAway for checking nilability in switch cases:

switch {
case a == nil:
case a.f == nil: // NilAway won't complain about a being potentially nil
}

However, if there are exhaustive combinations of another boolean variable:

switch {
case a == nil && b:
case a == nil && !b:
case a.f == nil: // False positive!
}

It would be very expensive to reason about the general cases (different combinations of many boolean variables) -- we need an SMT solver for that. However, for cases like this with only one boolean variable, we could probably add some support for it.

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