nilaway
nilaway copied to clipboard
False positive when there are already exhaustive combinations in switch cases
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.