For the below case, NilAway correctly tracks the implication of slicing an empty slice and does not report an error.
var x []int
_ = x[:0]
However, when the slicing index is a non-literal, like below, NilAway currently reports a false positive. Refine tracking of non-literal indices to understand such code patterns and avoid false positives. Update func (r *RootAssertionNode) isZeroSlicing(expr *ast.SliceExpr) bool { ... } method to add the support.
var x []int
_ = x[:min(len(x), 100)] // FP: unassigned variable `x` sliced into
For the below case, NilAway correctly tracks the implication of slicing an empty slice and does not report an error.
However, when the slicing index is a non-literal, like below, NilAway currently reports a false positive. Refine tracking of non-literal indices to understand such code patterns and avoid false positives. Update
func (r *RootAssertionNode) isZeroSlicing(expr *ast.SliceExpr) bool { ... }
method to add the support.