nilaway icon indicating copy to clipboard operation
nilaway copied to clipboard

False positive when there are already exhaustive combinations in switch cases

Open yuxincs opened this issue 3 months ago • 0 comments

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.

yuxincs avatar Mar 12 '24 17:03 yuxincs